Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux ping broadcast switch

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.

like image 932
Mei Avatar asked Sep 23 '10 21:09

Mei


2 Answers

You could put

alias ping='ping -b'

in your .bashrc file :-)

like image 96
Richard Fearn Avatar answered Nov 13 '22 04:11

Richard Fearn


I can conceivably think of one scenario where this might be useful. If you're on a network with a configured broadcast address that is not the address where all host bits are one. Thus you could conceivably accidentally ping the broadcast address if there wasn't such a prompt. And I guess that's bad.

like image 25
jdizzle Avatar answered Nov 13 '22 05:11

jdizzle