Linux : Ping all the host in the subnet

You can always try to ping to the broadcast address of your subnet. It depends on your local network setup, but you can find it out with

$ ifconfig wlp4s0 | grep Bcast
      inet addr:192.168.199.47  Bcast:192.168.199.255  Mask:255.255.255.0

Pinging from Linux requires the -b commandline switch, which is kind of a precaution of the command.

However, this does not guarantee that you will collect all MAC addresses from all devices connected to your subnet as it is up the the very device to actually answer ICMP ECHO requests sent to broadcast addresses, even if that was intended otherwise in the early ages of the TCP/IP RFCs (see whether /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts is set to 1).

To be more sure to cover all addresses, ping them individually with

$ for ip in 192.168.199.{1..254}; do ping -c1 ${ip} & done

More or less the same is achieved if you use a special scan type of nmap with

$ sudo nmap -sn -PE -n 192.168.179.1-254

That is also my recommended way of probing since you can fine tune the way you ask the clients for their MAC addresses.


All you are doing is pinging the broadcast address. The GNU/Linux version of ping requires that you use the -b switch

-b Allow pinging a broadcast address

There doesn't appear to be a direct equivalent of the Solaris -s switch either (it's only pinging every second and gathering stats) but perhaps it's buried in the Linux man pages- well worth a read (as may be the Solais ones ).

I wouldn't go pinging 255.255.255.255 either (it may take a while to complete) I'd use the broadcast address of the network I was connected to.