如何調試虛擬 Linux 介面的「網路無法存取」錯誤

如何調試虛擬 Linux 介面的「網路無法存取」錯誤

我的系統中只有環回(lo)和虛擬介面。我關閉了所有其他介面。我還停止了防火牆、selinux 和 iptables。我想 ping 路由表中的 IP 位址,但收到如下「網路無法存取」錯誤。

我想學什麼我該如何解決這樣的問題? dmesg 或系統訊息沒有顯示任何內容。為什麼介面無法存取以及如何找出問題所在。

先致謝

# ping 172.99.0.2
PING 172.99.0.2 (172.99.0.2) 56(84) bytes of data.
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable

# ifconfig 
gtp1: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 0
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 479  bytes 40888 (40.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 479  bytes 40888 (40.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.99.0.2      0.0.0.0         255.255.255.255 UH    0      0        0 gtp1

# find / -name gtp1
/proc/sys/net/ipv4/conf/gtp1
/proc/sys/net/ipv4/neigh/gtp1
/sys/class/net/gtp1
/sys/devices/virtual/net/gtp1

答案1

嗯,儘管該位址位於路由表中,但您無法 ping 通該位址,因為指派給該路由的介面本身沒有 IP。所以你的主機無法在那裡發送資料包。

一般來說,當您想了解網路時,我建議開始使用 Wireshark/tcpdump。透過這種方式,您將看到資料包如何流動、尋址如何運作、您擁有哪些低階流量等。

相關內容