I discovered a wonderful utility last night:
nast. I wanted to scan my local network, just to see what devices were on it, what their addresses were, etc. I could ping my entire subnet, but what if I had a machine that rejected ICMP packets? (Not that I do very often, but it can happen in larger environments). I thought using a protocol like ARP would be much more robust, since it is pretty much guaranteed to be available. Then I discovered nast.
nast can do a lot of neat things. The first I found was mapping a subnet of course, which you can do by running
sudo nast -i eth1 -m
adjusting the interface to fit. It will return something like:
Nast V. 0.2.0
Mapping the Lan for 255.255.255.0 subnet ... please wait
MAC address Ip address (hostname)
===========================================================
00:19:D2:92:20:CE 192.168.1.1 (MyGateway)
00:1B:C0:B7:86:CB 192.168.1.2 (MyBox) (*)
00:14:38:E5:76:10 192.168.1.5 (SomeOtherBox)
nast can also try to find out if there are any nodes on your subnet acting in promiscuous mode, which I think is pretty hot. Check out the main
nast page for the full feature set.
In my searching, I also came across
fping. Its main improvements over regular old ping are:
- More than one host can be passed (as well as a file containing hosts)
- Its output is very simple and easy to parse, making it ideal for scripting
- It tries each host and moves on if there is no response, making the whole process faster
Instead of
ping -c 1 myhost1 ; ping -c 1 myhost2
you can just run
fping myhost1 myhost2
which just returns
myhost1 is alive
myhost2 is alive
Both nast and fping are available in the Ubuntu repos.