我知道IPv6允许省略连续的零。但是IPv4呢?我在Internet上找不到任何对此的引用,包括Wikipedia和RFC 791 – Internet协议。该文档 建议在IPv4地址中使用“前导零可以省略”(搜索术语“省略”)。不够具体。
看看这个shell会话:
[~]$ ping -c 1 127.1
PING 127.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.040 ms
--- 127.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.040/0.040/0.040/0.000 ms
[~]$ ping -c 1 127.0.1
PING 127.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.044 ms
--- 127.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.044/0.044/0.044/0.000 ms
[~]$ ssh 127.1 :
The authenticity of host '127.1 (127.0.0.1)' can't be established.
ECDSA key fingerprint is 04:48:fa:f2:ef:95:7c:35:46:39:2e:d3:89:dd:cd:87.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '127.1' (ECDSA) to the list of known hosts.
alex@127.1's password:
显然,ping和ssh都将127.1和127.0.1理解为与127.0.0.1相同。在哪里指定?
7
此Stack Overflow帖子中链接的此手册页可能就在您的小巷。
—
nerdwaller
那是一种古老的记谱法,但是是的:它确实起作用:-)
—
Sander Steffann
@nerdwaller:请发布答案。(如果您弄清楚原因
—
user1686
ping 0.0.0.0
或ping 0
工作方式相同,则加分。)