Linux / UNIX: Ping a Block of Hosts (netblock)

by Vivek Gite on January 8, 2009 · 6 comments

Q. How do I ping a block of hosts such as 192.168.1.0/24?

A. You can use ping or fping. The -g option generate a target list from a supplied IP netmask, or a starting and ending IP. Specify the netmask or start/end in the targets portion of the command line.

fping command

To ping the class C 192.168.1.0/24, the specified command line could look like either:
$ fping -g 192.168.1.0/24
OR
$ fping -g 192.168.1.0 192.168.1.255

ping command

You can also use ping command, enter:

for i in {1..254}; do ping -c1 192.168.1.$i; done

There are other options like nmap, nbtscan, Windows NT / Server specific loop discussed here.

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 6 comments… read them below or add one }

1 someone January 8, 2009

It should be like this command:

for i in {1..254}; do ping -c1 192.168.1.$i; done

Reply

2 Vivek Gite January 8, 2009

Thanks for the heads up.

Reply

3 elinusliga January 9, 2009

Perfect…thank you for the post.

Reply

4 Rafael Bezerra do Nascimento January 9, 2009

I use Nmap
# nmap -sP 192.168.0.*
or
# nmap -sP 192.168.0.1-200

Reply

5 Mark Sanborn January 14, 2009

That is awesome. Also like the nmap version :)

Reply

6 Jasleen May 10, 2009

what about the same procedure in RHEL 5

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 9 + 8 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: