对路由和网络掩码感到困惑

对路由和网络掩码感到困惑

我在使用 OpenVPN 和多个 VPN 时遇到了一些问题。虽然不是惊天动地的问题,但在引入了我不打算引入的 VPN 组合后,我陷入了一种我无法理解的境地。查看以下输出;

C:\Users\craig>route print
===========================================================================
Interface List
 60...........................Nlwt Tun
  5...00 ff 28 fe 53 4f ......TAP-NordVPN Windows Adapter V9
 16...a8 6d aa 2b 75 b9 ......Intel(R) Wireless-AC 9260 160MHz
 21...a8 6d aa 2b 75 ba ......Microsoft Wi-Fi Direct Virtual Adapter
 17...aa 6d aa 2b 75 b9 ......Microsoft Wi-Fi Direct Virtual Adapter #2
 14...c8 f7 50 3e 3b 20 ......Intel(R) Ethernet Connection (7) I219-LM
  8...00 ff 3a cd cd 66 ......TAP-Windows Adapter V9
 22...00 ff e8 c6 1b 54 ......TAP-Windows Adapter V9 #2
  9...00 ff 49 67 a3 95 ......TAP-Windows Adapter V9 #3
 12...a8 6d aa 2b 75 bd ......Bluetooth Device (Personal Area Network)
  1...........................Software Loopback Interface 1
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0    192.168.8.254    192.168.8.166     35
          0.0.0.0        128.0.0.0  192.168.145.129  192.168.145.221     35
          0.0.0.0        128.0.0.0         10.7.3.1         10.7.3.3     35
         10.7.3.0    255.255.255.0         On-link          10.7.3.3    291
         10.7.3.3  255.255.255.255         On-link          10.7.3.3    291
       10.7.3.255  255.255.255.255         On-link          10.7.3.3    291
         10.8.0.1  255.255.255.255        10.8.0.29        10.8.0.30     35
        10.8.0.28  255.255.255.252         On-link         10.8.0.30    291
        10.8.0.30  255.255.255.255         On-link         10.8.0.30    291
        10.8.0.31  255.255.255.255         On-link         10.8.0.30    291
     92.12.132.63  255.255.255.255    192.168.8.254    192.168.8.166     35
        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
        128.0.0.0        128.0.0.0  192.168.145.129  192.168.145.221     35
        128.0.0.0        128.0.0.0         10.7.3.1         10.7.3.3     35
      192.168.8.0    255.255.255.0         On-link     192.168.8.166    291
    192.168.8.166  255.255.255.255         On-link     192.168.8.166    291
    192.168.8.255  255.255.255.255         On-link     192.168.8.166    291
    192.168.145.0    255.255.255.0         On-link   192.168.145.221    291
  192.168.145.221  255.255.255.255         On-link   192.168.145.221    291
  192.168.145.255  255.255.255.255         On-link   192.168.145.221    291
   195.206.183.56  255.255.255.255    192.168.8.254    192.168.8.166     35
        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.8.0.30    291
        224.0.0.0        240.0.0.0         On-link   192.168.145.221    291
        224.0.0.0        240.0.0.0         On-link          10.7.3.3    291
        224.0.0.0        240.0.0.0         On-link     192.168.8.166    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.8.0.30    291
  255.255.255.255  255.255.255.255         On-link   192.168.145.221    291
  255.255.255.255  255.255.255.255         On-link          10.7.3.3    291
  255.255.255.255  255.255.255.255         On-link     192.168.8.166    291
===========================================================================
Persistent Routes:
  None

IPv6 Route Table
===========================================================================
Active Routes:
 If Metric Network Destination      Gateway
  1    331 ::1/128                  On-link
  1    331 ff00::/8                 On-link
===========================================================================
Persistent Routes:
  None

C:\Users\craig>ping 10.7.0.1

Pinging 10.7.0.1 with 32 bytes of data:
Reply from 10.7.0.1: bytes=32 time=38ms TTL=64
Reply from 10.7.0.1: bytes=32 time=38ms TTL=64
Reply from 10.7.0.1: bytes=32 time=38ms TTL=64

Ping statistics for 10.7.0.1:
    Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 38ms, Maximum = 38ms, Average = 38ms

C:\Users\craig>ipconfig

Windows IP Configuration

Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . : home
   IPv4 Address. . . . . . . . . . . : 192.168.8.166
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.8.254

Ethernet adapter Ethernet 2:

   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 10.8.0.30
   Subnet Mask . . . . . . . . . . . : 255.255.255.252
   Default Gateway . . . . . . . . . :

Ethernet adapter Ethernet 3:

   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 192.168.145.221
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

Ethernet adapter Ethernet 4:

   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 10.7.3.3
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :


我可以 ping 10.7.0.1,这对于 Windows 文件共享来说工作正常,但我认为它不应该工作。其中唯一的 10.7.xx 是 10.7.3.x,由于没有一个网络掩码允许第三个八位字节变化,这台机器如何成功路由到 10.7.0.x?我是否遗漏了网关和网络掩码如何组合以指示网关可用于的地址?

应该这里有一个到 10.8.0.1 的 VPN、一个到 10.7.0.1 的 VPN 以及物理网络 192.168.8.x 和 192.168.145.x(实际上已断开连接)。10.7.3.3 是一个 NordVPN,它意外地在启动时启动,还有其他一些在没有更多可用 TAP 接口时出错的 VPN。

答案1

你的第一行:

Network Destination        Netmask          Gateway       Interface  Metric
      0.0.0.0          0.0.0.0    192.168.8.254    192.168.8.166     35

列出默认路由。默认路由匹配任何没有更具体路由匹配的路由。因此,当您 ping 10.7.0.1 时,PC 会寻找到达该目的地的最佳(最长)路由。由于没有其他路由匹配,因此将使用默认路由。

如果没有默认路由,您将需要一条通往互联网上每个网络的路由(目前大约有 400,000 条路由)。您的路由表中会有大量的条目 :)

相关内容