Tuesday August 24, 2010 at 03:47
Subject: A very useful tool: fping
Keywords:
NCLUG, Networking, Technical
Posted by: Sean Reifschneider
Recently a friend was saying that one of his co-workers doesn't really
write scripts, and had asked my friend to write a script to ping a bunch of
hosts. The use was for inventory in preparation for a big move, to make
sure they weren't missing hosts or IPs that needed to be moved.
I immediately recommended "fping". It's default mode will read target
names from stdin and ping them, and it times out after a few tries,
displaying the results. It also pings them asynchronously, so pinging huge
sets of hosts goes pretty fast. In a test here, I ran it on a 254
addresses in 35 seconds.
Read on for more details and examples of what fping can do.
For example, by default fping will read the hosts to ping either from
the command-line or from stdin (one line per host):
(Post Reply)
guin:contrib$ echo 10.1.5.{1,2,3,4,5} | fmt -1 | fping
10.1.5.3 is alive
10.1.5.4 is alive
ICMP Host Unreachable from 10.55.2.1 for ICMP Echo sent to 10.1.5.1
[...]
10.1.5.1 is unreachable
10.1.5.2 is unreachable
10.1.5.5 is unreachable
guin:contrib$
Note that nmap can also ping hosts and read the list of hosts from
stdin, with the command-line "nmap -sP -iL -".
One thing I commonly do is to use the "-g" option to have fping
generate all the addresses to ping: "fping -g 10.1.5.0/24". This pings all
254 addresses in the specified block.
For a quicker ping you can use "-c 1" to only send one packet.
Usually it will send several packets just to make sure that you get
responses from all the hosts it can. For example: "fping -c 1 -g 10.1.5.0/24"
takes only 10 seconds to run where without the "-c 1" it takes 35.
You can also use "-c" with a larger number, and combine it with "-q"
(quiet) to get some nice, general statistics about the host's network
reachability: "fping -c 5 -q 10.1.5.4" will result in the output "10.1.5.4
: xmt/rcv/%loss = 5/5/0%, min/avg/max = 1.46/1.50/1.59".
The "-q" option alone will simply set the process exit code as to
whether the host is up. So if you want to make sure a machine is up before
doing something, you could run "fping -q 10.1.5.4 && $SOME_OTHER_COMMAND".
There are also arguments allowing you to control how quickly
retransmissions are sent, how many retries, and data display formats.
fping is a great tool that I've come to rely on.
(Post Reply)
| Comment |
Steve Webb Subject: smokeping uses fping |
I use smokeping to check for changes in latency over certain links and it uses fping, so I became aware of it through smokeping. Nice tool.