开发者

Linux ping broadcast switch

开发者 https://www.devze.com 2023-01-17 04:13 出处:网络
When using ping on virtually every UNIX system available, pinging the broadcast address is simple: $ ping 192.168.11.255

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!) resp开发者_JAVA技巧onse 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.


You could put

alias ping='ping -b'

in your .bashrc file :-)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号