我有三个路由器:
- 路由器 1 具有外部互联网连接。其 LAN IP 为 192.168.0.1,并提供 192.168.0.* 子网中的 IP 地址。
- 路由器 2 通过路由器 1 访问互联网。它的 WAN IP(在路由器 1 的网络上)为 192.168.0.20,LAN IP 为 192.168.68.1,并在 192.168.68.* 子网中提供 IP 地址。
- 路由器 3 通过路由器 2 访问互联网。它的 WAN IP(在路由器 2 的网络上)为 192.168.68.122,LAN IP 为 192.168.13.1,并提供 192.168.13.* 子网中的 IP 地址。
我有一台 Windows PC 连接到路由器 1,其 LAN IP 地址为 192.168.0.2。我希望能够从这台 PC 访问路由器 2 和路由器 3 网络上的设备。
为了实现此功能,我运行了以下命令:
route -p ADD 192.168.13.0 MASK 255.255.255.0 192.168.68.122 metric 1 if 30
route -p ADD 192.168.68.0 MASK 255.255.255.0 192.168.0.20 metric 1 if 30
route print
这导致了该问题底部给出的输出,表明它已设置好。
但是,我无法ping
通过新路由连接任一网络上的机器。例如:
C:\Users\Tom>ping 192.168.0.20 -n 1
Pinging 192.168.0.20 with 32 bytes of data:
Reply from 192.168.0.20: bytes=32 time<1ms TTL=64
Ping statistics for 192.168.0.20:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:\Users\Tom>ping 192.168.68.1 -n 1
Pinging 192.168.68.1 with 32 bytes of data:
Request timed out.
Ping statistics for 192.168.68.1:
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
C:\Users\Tom>ping 192.168.68.122 -n 1
Pinging 192.168.68.122 with 32 bytes of data:
Request timed out.
Ping statistics for 192.168.68.122:
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
C:\Users\Tom>ping 192.168.13.1 -n 1
Pinging 192.168.13.1 with 32 bytes of data:
Request timed out.
Ping statistics for 192.168.13.1:
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
如果路由器 3 的网络无法访问,我可以理解。(我不知道路由表是否支持此处所需的两步路由。)但很难理解为什么路由器 2 的网络无法访问。
我究竟做错了什么?
route print
输出:
C:\Users\Tom>route print
===========================================================================
Interface List
22...00 ff 90 d2 fc 16 ......Juniper Network Connect Virtual Adapter
30...a4 bb 6d b3 8c a1 ......Intel(R) Ethernet Connection (5) I219-LM
18...0a 00 27 00 00 12 ......VirtualBox Host-Only Ethernet Adapter
25...00 ff aa 18 81 ac ......TAP-Windows Adapter V9
37...00 ff bd b8 d5 c4 ......TeamViewer VPN Adapter
6...44 01 bb a8 cb 97 ......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.0.1 192.168.0.2 281
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
192.168.0.0 255.255.255.0 On-link 192.168.0.2 281
192.168.0.2 255.255.255.255 On-link 192.168.0.2 281
192.168.0.255 255.255.255.255 On-link 192.168.0.2 281
192.168.13.0 255.255.255.0 192.168.68.122 192.168.0.2 26
192.168.56.0 255.255.255.0 On-link 192.168.56.1 281
192.168.56.1 255.255.255.255 On-link 192.168.56.1 281
192.168.56.255 255.255.255.255 On-link 192.168.56.1 281
192.168.68.0 255.255.255.0 192.168.0.20 192.168.0.2 26
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 192.168.56.1 281
224.0.0.0 240.0.0.0 On-link 192.168.0.2 281
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 192.168.56.1 281
255.255.255.255 255.255.255.255 On-link 192.168.0.2 281
===========================================================================
Persistent Routes:
Network Address Netmask Gateway Address Metric
0.0.0.0 0.0.0.0 192.168.0.1 Default
192.168.68.0 255.255.255.0 192.168.0.20 1
192.168.13.0 255.255.255.0 192.168.68.122 1
===========================================================================
IPv6 Route Table
===========================================================================
Active Routes:
If Metric Network Destination Gateway
30 41 ::/0 fe80::1
1 331 ::1/128 On-link
30 41 2003:c9:f72b:a824::/64 On-link
30 281 2003:c9:f72b:a824:cd5f:d85f:eddb:aad2/128
On-link
30 281 2003:c9:f72b:a824:d143:ab14:fc96:dced/128
On-link
30 281 2003:c9:f72b:a824:d984:866c:9de8:9a5c/128
On-link
30 41 2003:c9:f72b:a834::/64 On-link
30 281 2003:c9:f72b:a834:99fb:2a0d:280d:bf6f/128
On-link
30 281 2003:c9:f72b:a834:d143:ab14:fc96:dced/128
On-link
30 281 2003:c9:f72b:a834:d984:866c:9de8:9a5c/128
On-link
30 41 2003:c9:f72b:a855::/64 On-link
30 281 2003:c9:f72b:a855:ad8f:d4ac:5f38:682d/128
On-link
30 281 2003:c9:f72b:a855:d984:866c:9de8:9a5c/128
On-link
18 281 fe80::/64 On-link
30 281 fe80::/64 On-link
18 281 fe80::11db:d621:42c7:94fb/128
On-link
30 281 fe80::d984:866c:9de8:9a5c/128
On-link
1 331 ff00::/8 On-link
18 281 ff00::/8 On-link
30 281 ff00::/8 On-link
===========================================================================
Persistent Routes:
None
答案1
为了使数据包正确流动,必须满足以下两个要求:
- 路由器 2 和路由器 3 不得启用 NAT。
- 所有节点上必须存在正确的路由条目:
在路由器 1 上:
192.168.68.0/24
必须存在到路由器的路由192.168.0.20
192.168.13.0/24
必须存在到路由器的路由192.168.0.20
在路由器 2 上:
- 必须存在到 的路由
192.168.0.0/24
。这自动是一条在线路由。 - 必须存在到 的路由
192.168.13.0/24
。这自动是一条在线路由。
在路由器 3 上:
- 必须存在到 的路由
192.168.0.0/24
,即路由器192.168.68.1
。 - 必须存在到 的路由
192.168.68.0/24
。这自动是一条在线路由。
上的路由router 3
已被默认路由覆盖。