Thursday, December 26, 2013

Ping multiple hotsts at once on Linux


fping – Ping multiple hotsts at once on Linux


fping is a ping like program which uses the Internet Control Message Protocol (ICMP) echo request to determine if a host is up. fping is different from ping in that you can specify any number of hosts on the command line, or specify a file containing the lists of hosts to ping.
Instead of trying one host until it timeouts or replies, fping will send out a ping packet and move on to the next host in a round-robin fashion. If a host replies, it is noted and removed from the list of hosts to check. If a host does not respond within a certain time limit and/or retry limit it will be considered unreachable.
Unlike ping, fping is meant to be used in scripts and its output is easy to parse.
Scanning a network should not be done without prior permission. Many networks and systems will view a network scan as an aggressive action regardless of how trivial and petty it might be. Please keep this in mind before utilizing this tool.
For CentOs 5.x/6.x this utility is provided from the EPEL repository , just install it with :
yum install fping

Let’s start with a very simple scan, our own system:
fping  192.168.1.1
Nice …. it return that our router is alive
192.168.1.1 is alive
fping -a < ip_list.txt
Let’s try scanning a larger chunk of our network using a file for input instead of typing in IP addresses at the command line:
192.168.1.1 is alive
192.168.1.3 is alive
fping -f ip_list.txt
e file “ip_table.txt” just contains the IP addresses from 192.168.1.0 to 192.168.1.10 with each IP address on its own line. In my above command line example I piped in the file. If you are logged into your system as root you can use this command instead:
fping -a -d < ip_list.txt
The -d flag will attempt to resolve host names for each IP address while the -a flag will only show alive hosts. Again I piped a list of IP addresses into fping.
fping -g 192.168.1.0/24
If you wanted to specify a range of IP addresses at the command line, say all 255 possible hosts of 192.168.1.*, you could use the -g flag


There are quite a few more options capable of being used with fping. I would recommend reading the man page for fping to learn more about this tool.
If you want to quickly scan a network for reachable hosts then fping will easily provide you with that capability. It is a simple tool that can be run while you work on other things should you need to scan a large network (but not as long as ping!). It is also worth learning because fping can be incorporated into your own custom scripts since it’s output is easy to parse. A drawback to using fping is that the perimeter of networks will often block ICMP traffic into the internal network. This is overcome by using nmap which we’ll look at another day. Happy scanning!

No comments:

Post a Comment