Windows

由於路由無效,某些 IP 地址無法訪問

  • April 2, 2018

我想連接到遠端機器。問題是我可以連接到除一台以外的每一台機器。經過一番調查,我發現問題出在路線上。這是範例:

PS C:\Users\Alex> tracert 172.17.56.66

Tracing route to 172.17.56.66 over a maximum of 30 hops

 1    31 ms     9 ms    12 ms  10.19.64.1
 2     9 ms    14 ms     8 ms  172.17.56.66

Trace complete.
PS C:\Users\Alex> tracert 172.17.56.68

Tracing route to 172.17.56.68 over a maximum of 30 hops

 1    13 ms     7 ms     7 ms  10.19.64.1
 2    10 ms     5 ms     4 ms  172.17.56.68

Trace complete.
PS C:\Users\Alex> tracert 172.17.56.70

Tracing route to 172.17.56.70 over a maximum of 30 hops

 1    <1 ms    <1 ms    <1 ms  192.168.0.1
 2     8 ms    41 ms     7 ms  188.170.9.10
 3    96 ms     1 ms     1 ms  192.168.1.1
 4     1 ms    <1 ms    <1 ms  10.90.40.41
 5     1 ms     1 ms     1 ms  10.90.40.34
 6     1 ms     1 ms     1 ms  10.90.40.32
 7     3 ms     8 ms     2 ms  10.90.35.80
 8     *        *     10.90.35.78  reports: Destination net unreachable.

Trace complete.

我不知道為什麼它以不同的方式處理這個IP。這是我的route print

===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
         0.0.0.0          0.0.0.0      192.168.0.1    192.168.0.239     35
    10.19.84.212  255.255.255.252         On-link      10.19.84.214    311
    10.19.84.214  255.255.255.255         On-link      10.19.84.214    311
    10.19.84.215  255.255.255.255         On-link      10.19.84.214    311
       127.0.0.0        255.0.0.0         On-link         127.0.0.1    331
       127.0.0.1  255.255.255.255         On-link         127.0.0.1    331
 127.255.255.255  255.255.255.255         On-link         127.0.0.1    331
    172.17.56.65  255.255.255.255     10.19.84.213     10.19.84.214     55
    172.17.56.66  255.255.255.255     10.19.84.213     10.19.84.214     55
    172.17.56.67  255.255.255.255     10.19.84.213     10.19.84.214     55
    172.17.56.68  255.255.255.255     10.19.84.213     10.19.84.214     55
    172.17.56.69  255.255.255.255     10.19.84.213     10.19.84.214     55
    172.17.56.72  255.255.255.255     10.19.84.213     10.19.84.214     55
    172.17.56.73  255.255.255.255     10.19.84.213     10.19.84.214     55
     192.168.0.0    255.255.255.0         On-link     192.168.0.239    291
   192.168.0.239  255.255.255.255         On-link     192.168.0.239    291
   192.168.0.255  255.255.255.255         On-link     192.168.0.239    291
       224.0.0.0        240.0.0.0         On-link         127.0.0.1    331
       224.0.0.0        240.0.0.0         On-link      10.19.84.214    311
       224.0.0.0        240.0.0.0         On-link     192.168.0.239    291
 255.255.255.255  255.255.255.255         On-link         127.0.0.1    331
 255.255.255.255  255.255.255.255         On-link      10.19.84.214    311
 255.255.255.255  255.255.255.255         On-link     192.168.0.239    291
===========================================================================
Persistent Routes:
 None

所以在我靜態添加之後(基於66和68網關)

route ADD -p 172.17.56.70 MASK 255.255.255.255 10.19.84.213

有效。但是為什麼網關在其他情況下會自動檢測,但在這種情況下我應該對其進行硬編碼?

您的預設網關是 192.168.0.1。因此,如果沒有靜態路由,流量將通過預設網關,直連網路除外。在上面的 172.17.56.70 範例中,您希望將流量發送到不同的網關 10.19.84.213。唯一的方法是添加靜態路由。這是正常行為。

引用自:https://serverfault.com/questions/905644