情景: Windows 电脑 想要存取 Linux 电脑里面 z/OS 主机
z/OS 主机 跟 Linux 电脑 使用内部 tunnel 管道连接
Linux 电脑
192.168.50.15
Windows 电脑
192.168.50.16
Linux 电脑管道
192.168.200.2
z/OS 主机管道
192.168.200.1
先用管理员开起 Command Prompt
用 route print 来查看现在路由
C:\Windows\system32>route print
... ...
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.50.1 192.168.50.16 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.50.0 255.255.255.0 On-link 192.168.50.16 281
192.168.50.16 255.255.255.255 On-link 192.168.50.16 281
192.168.50.255 255.255.255.255 On-link 192.168.50.16 281
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.50.16 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.50.16 281
===========================================================================
Persistent Routes:
Network Address Netmask Gateway Address Metric
0.0.0.0 0.0.0.0 192.168.50.1 Default
===========================================================================
IPv6 Route Table
===========================================================================
Active Routes:
If Metric Network Destination Gateway
1 331 ::1/128 On-link
11 281 fe80::/64 On-link
11 281 fe80::4420:e0:bab0:a768/128
On-link
1 331 ff00::/8 On-link
11 281 ff00::/8 On-link
===========================================================================
Persistent Routes:
None
C:\Windows\system32>
**Remark: Need to restart PC
做法是 把 192.168.50.16 (Windows 电脑) 发往 192.168.200.1 (z/OS 主机) 的包, 都路由到 192.168.50.15 (Linux 电脑)
可以用 route add 指令
C:\Windows\system32>route add 192.168.200.0 mask 255.255.255.0 192.168.50.15 -p
OK!
注: -p 是 persistent 开机也维持路由
再查看
C:\Windows\system32>route print
... ...
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.50.1 192.168.50.16 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.50.0 255.255.255.0 On-link 192.168.50.16 281
192.168.50.16 255.255.255.255 On-link 192.168.50.16 281
192.168.50.255 255.255.255.255 On-link 192.168.50.16 281
192.168.200.0 255.255.255.0 192.168.50.15 192.168.50.16 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.50.16 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.50.16 281
===========================================================================
Persistent Routes:
Network Address Netmask Gateway Address Metric
0.0.0.0 0.0.0.0 192.168.50.1 Default
192.168.200.0 255.255.255.0 192.168.50.15 1
===========================================================================
IPv6 Route Table
===========================================================================
Active Routes:
If Metric Network Destination Gateway
1 331 ::1/128 On-link
11 281 fe80::/64 On-link
11 281 fe80::4420:e0:bab0:a768/128
On-link
1 331 ff00::/8 On-link
11 281 ff00::/8 On-link
===========================================================================
Persistent Routes:
None
如果要删除可以用 route delete 指令
C:\Windows\system32>route delete 192.168.200.0 mask 255.255.255.0
OK!
如果 Linux 电脑 开了防火墙,增加 Windows 电脑 允许
sudo ufw allow from 192.168.50.16
sudo ufw reload