如何在没有路由表条目的情况下 ping 环回 IP?

如何在没有路由表条目的情况下 ping 环回 IP?

ifconfig的输出:

$ ifconfig
enp4s0f1  Link encap:Ethernet  HWaddr f8:32:e4:d3:a1:4e  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4834 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4834 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:381278 (381.2 KB)  TX bytes:381278 (381.2 KB)

wlp3s0    Link encap:Ethernet  HWaddr 80:a5:89:0d:0d:69  
          inet addr:192.168.1.34  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::560a:df95:1d4f:120d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:44489 errors:0 dropped:0 overruns:0 frame:0
          TX packets:48510 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:29226622 (29.2 MB)  TX bytes:6653647 (6.6 MB)

我有环回接口,但是当我看到我的路由表时:

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    600    0        0 wlp3s0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlp3s0
192.168.1.0     0.0.0.0         255.255.255.0   U     600    0        0 wlp3s0

没有任何路由条目127.x.x.x

但是我怎样才能 ping 通它们呢?

$ ping 127.0.0.1
PING 127.0.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.019 ms
....

答案1

环回地址不需要路由,因为发往环回接口的数据包不会离开接口,也不会传递到数据链路层。

相关内容