我有幾個 Linux 來賓虛擬機,它們透過橋接網路連接到我的實體適配器。由於某種原因,我無法為來賓使用主機的子網路(虛擬適配器對我來說太慢),因此我為它們創建了一個單獨的子網路。
在主機上我新增了來賓子網路:
C:\> route add 192.168.20.0 mask 255.255.255.0 0.0.0.0 metric 1
關於客人:
# route add -host 192.168.148.87 dev eth3 # my host ip
它主要工作:
basin@BASIN /cygdrive/c/Users/basin
$ tracert -d 192.168.20.20
Tracing route to 192.168.20.20 over a maximum of 30 hops
1 <1 ms <1 ms <1 ms 192.168.20.20
Trace complete.
basin@BASIN /cygdrive/c/Users/basin
$ tracert -d 192.168.20.21
Tracing route to 192.168.20.21 over a maximum of 30 hops
1 <1 ms <1 ms <1 ms 192.168.20.21
Trace complete.
但看起來有些資料包通過了網關:
basin@BASIN /cygdrive/c/Users/basin
$ tracert -d 192.168.20.23
Tracing route to 192.168.20.23 over a maximum of 30 hops
2 <1 ms <1 ms <1 ms 192.168.200.1 0
3 192.168.200.1 reports: Destination host unreachable.
Trace complete.
與來賓的 SSH 連結經常停滯。我究竟做錯了什麼?
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.149.200 192.168.148.87 20
127.0.0.0 255.0.0.0 On-link 127.0.0.1 306
127.0.0.1 255.255.255.255 On-link 127.0.0.1 306
127.255.255.255 255.255.255.255 On-link 127.0.0.1 306
192.168.20.0 255.255.255.0 On-link 192.168.148.87 21
192.168.20.255 255.255.255.255 On-link 192.168.148.87 276
192.168.56.0 255.255.255.0 On-link 192.168.56.1 266
192.168.56.1 255.255.255.255 On-link 192.168.56.1 266
192.168.56.255 255.255.255.255 On-link 192.168.56.1 266
192.168.148.0 255.255.254.0 On-link 192.168.148.87 276
192.168.148.87 255.255.255.255 On-link 192.168.148.87 276
192.168.149.255 255.255.255.255 On-link 192.168.148.87 276
224.0.0.0 240.0.0.0 On-link 127.0.0.1 306
224.0.0.0 240.0.0.0 On-link 192.168.148.87 276
224.0.0.0 240.0.0.0 On-link 192.168.56.1 266
255.255.255.255 255.255.255.255 On-link 127.0.0.1 306
255.255.255.255 255.255.255.255 On-link 192.168.148.87 276
255.255.255.255 255.255.255.255 On-link 192.168.56.1 266
===========================================================================
更新:
作業系統是否會向不同的地方發送一些 ICMP 請求,並且回復會覆蓋我的靜態路由?如何檢查這個?
答案1
僅當目標位址不在直接連接的網路上時才使用靜態路由。在您的情況下,所有主機都位於直接連接的網路上,因此靜態路由將被忽略。