tags:

views:

31

answers:

1

Does anyone know how to use Ruby to grab a list of the MAC addresses of all the devices on the local network? Preferably as quick a response as possible.

Thanks!

+1  A: 

Substitute your actual IP range for the X's

ping -c 2 x.x.x.255

And then parse the results of an

arp -a
Azeem.Butt
Unfortunately this won't work very well cross-platform, don't suppose you know if Ruby has equivalent commands?
JP
Ruby's ping implementation does not use ICMP and there is no built-in ARP library that I'm aware of, so probably not.
Azeem.Butt
Shame - thanks!
JP
All the currently common operating systems I can think of will have the 'ping' and 'arp' commands if they have an IP stack. The command parameters would be slightly different, however (e.g. in Linux 'ping -c 1 ...' sends only one packet, where the Windows equivalent would be 'ping -n 1 ...'; and with NIX the command 'arp' will show the whole table, whereas with Windows you need to do 'arp -a').
ewall