为什么从选定的根 IPv6 ping 本地主机?

为什么从选定的根 IPv6 ping 本地主机?

Linux zika.gattaca.net 5.8.0-48-generic #54-Ubuntu SMP 星期五 3 月 19 日 14:25:20 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

我刚刚注意到,仅当我从根 IPv6 进行 ping 时才选择:

root@#########:/etc/samba# ping 本地主机

PING localhost(localhost (::1)) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.226 ms
64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.204 ms
64 bytes from localhost (::1): icmp_seq=3 ttl=64 time=0.177 ms
64 bytes from localhost (::1): icmp_seq=4 ttl=64 time=0.187 ms
64 bytes from localhost (::1): icmp_seq=5 ttl=64 time=0.142 ms
64 bytes from localhost (::1): icmp_seq=6 ttl=64 time=0.142 ms
64 bytes from localhost (::1): icmp_seq=7 ttl=64 time=0.213 ms
^C
--- localhost ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 137ms
rtt min/avg/max/mdev = 0.142/0.184/0.226/0.033 ms

brad@#########:~$ ping 本地主机

PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.194 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.131 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.130 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.133 ms
^C
--- localhost ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 80ms
rtt min/avg/max/mdev = 0.130/0.147/0.194/0.027 ms

在 /etc/hosts 中:

127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

如果我 ping 127.0.0.1 则使用 IPv4,OK 如果我 ping ::1 则使用 IPv6,OK

看起来名称解析不适用于用户,而仅适用于 root。

相关内容