简体   繁体   English

Linux Ping广播交换机

[英]Linux ping broadcast switch

When using ping on virtually every UNIX system available, pinging the broadcast address is simple: 在几乎每个可用的UNIX系统上使用ping时,对广播地址执行ping操作很简单:

$ ping 192.168.11.255

However, when this is done on Linux, a non-standard (and continually annoying!) response occurs: 但是,当在Linux上完成此操作时,会发生非标准(且一直很烦人!)响应:

$ 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. 自从我第一次看到它以来,这一直无休止地困扰着我-Linux ping以前不是这种方式。 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... 很想写一个补丁来修复Linux ping,非常诱人,因此它应该可以正常工作...

I can't believe no one else has complained about this, but I can't find it on Google if they did. 我无法相信没有其他人对此有所抱怨,但是如果他们这样做,我将无法在Google上找到它。

You could put 你可以放

alias ping='ping -b'

in your .bashrc file :-) 在您的.bashrc文件中:-)

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. 如果您的网络上配置的广播地址不是所有主机位都为1的地址。 Thus you could conceivably accidentally ping the broadcast address if there wasn't such a prompt. 因此,如果没有这样的提示,您可能会意外地对广播地址执行ping操作。 And I guess that's bad. 而且我认为那很糟糕。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM