Linux ping 广播开关
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3782807/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Linux ping broadcast switch
提问by Mei
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. 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.
自从我第一次看到它以来,这让我一直很恼火——Linux ping 过去不是这样的。我搜索了这个开关的来源,但找不到它何时进入或任何关于为什么有必要的讨论。
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.
我不敢相信没有其他人抱怨过这个,但如果他们这样做了,我在谷歌上找不到它。
回答by Richard Fearn
You could put
你可以把
alias ping='ping -b'
in your .bashrc
file :-)
在您的.bashrc
文件中:-)
回答by jdizzle
I can conceivably think of one scenario where this mightbe 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.
我可以想到一种可能有用的场景。如果您所在的网络配置的广播地址不是所有主机位都为 1 的地址。因此,如果没有这样的提示,您可能会意外地 ping 广播地址。我想这很糟糕。