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

Q. How do I ping a block of hosts such as


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, the specified command line could look like either:
$ fping -g
$ fping -g

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.

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

6 comments… add one
  • someone Jan 8, 2009 @ 15:50

    It should be like this command:

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

  • 🛡️ Vivek Gite (Author and Admin) nixCraft Jan 8, 2009 @ 16:20

    Thanks for the heads up.

  • elinusliga Jan 9, 2009 @ 6:12

    Perfect…thank you for the post.

  • Rafael Bezerra do Nascimento Jan 9, 2009 @ 13:04

    I use Nmap
    # nmap -sP 192.168.0.*
    # nmap -sP

  • Mark Sanborn Jan 14, 2009 @ 17:42

    That is awesome. Also like the nmap version :)

  • Jasleen May 10, 2009 @ 13:50

    what about the same procedure in RHEL 5

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.