5

There is one solaris command to ping all the hosts in the subnet by issuing :

ping -s 255.255.255.255

Is there anything similar to this one in linux ? My intention is to find one mac address as below after pinging all the hosts:

arp -an | grep mac_address
  • 1
    fping can do this. fping -c 1 -g 192.168.1.0/24 – Sven Dec 26 '16 at 13:00
  • I usually use ping6 -nc2 ff02::1%eth0 though it is not exactly the same as you ask for. – kasperd Dec 26 '16 at 20:11
2

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.

6

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.

0

Try

ping -b 10.0.0.255

at where ifconfig show broadcast address is 10.0.0.255

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.