Linux ping broadcast switch

Mei picture Mei · Sep 23, 2010 · Viewed 10.8k times · Source

When using ping on virtually every UNIX system available, pinging the broadcast address is simple:

$ ping 192.168.11.255

However, when this is done on Linux, a non-standard (and continually annoying!) response occurs:

$ ping 192.168.11.255
Do you want to ping broadcast? Then -b

This has annoyed me to no end ever since I saw it for the first time - Linux ping didn't used to be this way. I searched for the source of this switch, and can't find when it went in or any discussion as to why it was necessary.

It seems like this switch wasn't even deemed enough:

$ ping -b 192.168.11.255
WARNING: pinging broadcast address
PING 192.168.11.255 (192.168.11.255) 56(84) bytes of data.
64 bytes from 192.168.11.22: icmp_seq=1 ttl=64 time=0.225 ms

Is this really necessary? It's sorely tempting to write a patch that will fix Linux ping so it works like it should...

I can't believe no one else has complained about this, but I can't find it on Google if they did.

Answer

Richard Fearn picture Richard Fearn · Sep 23, 2010

You could put

alias ping='ping -b'

in your .bashrc file :-)