The second method uses a different command called fping. The fping command generates ICMP messages to multiple IP addresses and then waits to see which reply. It runs much faster than the first script.
The options available with fping include the following:
- The -a option with fping specifies to display the IP addresses for available machines
- The -u option with fping specifies to display unreachable machines
- The -g option specifies generating a range of IP addresses from the slash-subnet mask notation specified as IP/mask or start and end IP addresses:
$ fping -a 192.160.1/24 -g
Alternatively, this can be used:
$ fping -a 192.160.1 192.168.0.255 -g
- 2>/dev/null is used to dump error messages printed due to an unreachable host to a null device
It is also possible to manually specify a list of IP addresses as command-line arguments or as a list through stdin. Consider the following example:
$ fping -a 192.168.0.1 192.168.0.5 192.168.0.6 # Passes IP address as arguments $ fping -a <ip.list # Passes a list of IP addresses from a file