Ping Multiple Hosts Using Bash Nmap and Fping
I explained how to get a list of hosts using nmap -- using-nmap-to-generate-host-lists.html , but here is another look at the subject. The question is, how do I ping multiple hosts to find out which ones are down? Sure this could be considered a topic of system monitoring, but maybe you just want to reboot a bunch of machines, and make sure they all come back online. This quick check will tell you whether there is a problem or not. Here are three methods for pinging a list of hosts: 1.) for host in `cat all.txt `;do ping -c 1 $host; done 2.) nmap -sP -R -iL all.txt 3.) sudo fping -u < xyz/all.txt First, we assume that you have a text file named all.txt that contains a list of hostnames, one per line. Obviously, the examples here contain fake hostnames, domain names and IPs, as described in another article about vi: vim-tips-search-and-replace.html . --- all.txt --- xyz-1 xyz-2 xyz-3 xyz-4 xyz-5 xyz-6 xyz-7 xyz-8 --- end all.txt --- 1.) Use a for loop in ...
Comments