Windows 10 设定静态路由

本文介绍了如何配置Windows电脑的路由,使其能够通过Linux电脑的内部隧道连接到z/OS主机。首先,使用routeprint检查当前路由,然后使用routeadd命令添加一条持久路由,将发往z/OS主机的流量路由到Linux电脑。最后,如果Linux有防火墙,需要开启对Windows电脑的允许。此外,也提到了routedelete指令用于删除路由。
摘要由CSDN通过智能技术生成

情景: 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

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值