I needed to determine the IP addresses of all the hosts on a LAN from a Solaris 10 system. I knew that all of them will respond to pings. To do so, I used
fping. The fping program will allow you to quickly ping a range of hosts.
fping (Maintained by Thomas Dzubin)
fping is a ping(1) 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.
# gunzip fping-2.4b2-sol10-intel-local.gz # pkgadd -d ./fping-2.4b2-sol10-intel-local The following packages are available: 1 SMCfping fping (intel) 2.4b2 Select package(s) you wish to process (or 'all' to process all packages). (default: all) [?,??,q]: 1 Processing package instance
from fping(intel) 2.4b2 ZeroHype Technologies Inc. Using as the package base directory. ## Processing package information. ## Processing system information. 3 package pathnames are already properly installed. ## Verifying disk space requirements. ## Checking for conflicts with packages already installed. ## Checking for setuid/setgid programs. Installing fping as ## Installing part 1 of 1. /usr/local/doc/fping/COPYING /usr/local/doc/fping/ChangeLog /usr/local/doc/fping/INSTALL /usr/local/doc/fping/README /usr/local/man/man8/fping.8 /usr/local/sbin/fping [ verifying class ] Installation of was successful.
Program usage information is shown below:
# /usr/local/sbin/fping -h Usage: /usr/local/sbin/fping [options] [targets...] -a show targets that are alive -A show targets by address -b n amount of ping data to send, in bytes (default 56) -B f set exponential backoff factor to f -c n count of pings to send to each target (default 1) -C n same as -c, report results in verbose format -e show elapsed time on return packets -f file read list of targets from a file ( - means stdin) (only if no -g specified) -g generate target list (only if no -f specified) (specify the start and end IP in the target list, or supply a IP netmask) (ex. /usr/local/sbin/fping -g 192.168.1.0 192.168.1.255 or /usr/local/sbin/fping -g 192.168.1.0/24) -i n interval between sending ping packets (in millisec) (default 25) -l loop sending pings forever -m ping multiple interfaces on target host -n show targets by name (-d is equivalent) -p n interval between ping packets to one target (in millisec) (in looping and counting modes, default 1000) -q quiet (don't show per-target/per-ping results) -Q n same as -q, but show summary every n seconds -r n number of retries (default 3) -s print final stats -t n individual target initial timeout (in millisec) (default 500) -u show targets that are unreachable -v show version targets list of targets to check (if no -f specified)
If I wanted to determine what hosts in the 192.168.1.0 to 192.168.1.255 range
exist and can be pinged, I could use the command
fping -g 192.168.1.0
# /usr/local/sbin/fping -g 192.168.1.0 192.168.1.255 192.168.1.0 is alive [<- 192.168.1.44] 192.168.1.1 is alive 192.168.1.6 is alive 192.168.1.7 is alive 192.168.1.33 is alive 192.168.1.44 is alive 192.168.1.255 is alive [<- 192.168.1.44] 192.168.1.2 is unreachable 192.168.1.3 is unreachable 192.168.1.4 is unreachable 192.168.1.5 is unreachable 192.168.1.8 is unreachable 192.168.1.9 is unreachable 192.168.1.10 is unreachable <text snipped> 192.168.1.30 is unreachable 192.168.1.31 is unreachable 192.168.1.32 is unreachable 192.168.1.34 is unreachable 192.168.1.35 is unreachable <text snipped> 192.168.1.40 is unreachable 192.168.1.41 is unreachable 192.168.1.42 is unreachable 192.168.1.43 is unreachable 192.168.1.45 is unreachable <text snipped> 192.168.1.252 is unreachable 192.168.1.253 is unreachable 192.168.1.254 is unreachable
If I don't want anything displayed for IP addresses where there was no
response, I could use
fping -a -g <start address> <end
address>, as in the example below.
# /usr/local/sbin/fping -a -g 192.168.1.0 192.168.1.255 192.168.1.0 [<- 192.168.1.44] 192.168.1.1 192.168.1.5 192.168.1.7 192.168.1.37 192.168.1.44 192.168.1.255 [<- 192.168.1.44]
are network and broadcast addresses respectively, not hosts responding to
ping packets. The
192.168.1.44 address is the address of the
system from which I ran the ping command.