双网卡上不同网络,外网和内网

介绍

双网卡进不同的网段,一个进内网,一个进外网

在 windows 中输入 cmd 进入 dos 命令行;
输入 route print 查看路由信息(双网卡最大的问题就是路由的选择)

在这里,我的 172.16.4.1 为内网,192.168.0.250 为外网

使用 route delete 0.0.0.0 ,将这 2 条路由信息删除并以

route add -p 0.0.0.0 mask 0.0.0.0 192.168.0.250 metric 1
route add -p 0.0.0.0 mask 255.255.252.0 172.16.4.1 metric 20

来设置即可!

route 命令的相关信息,具体请查看系统说明!

destination Specifies the host.
MASK Specifies that the next parameter is the ‘netmask’ va
netmask Specifies a subnet mask value for this route entry.
If not specified, it defaults to 255.255.255.255.
gateway Specifies gateway.
interface the interface number for the specified route.
METRIC specifies the metric, ie. cost for the destination.

批处理

1
2
3
4
5
6
7
@echo off
color 0a
route delete 0.0.0.0
route add -p 0.0.0.0 mask 0.0.0.0 192.168.0.250 metric 1
route add -p 0.0.0.0 mask 255.255.252.0 172.16.4.1 metric 20
route print
pause
坚持原创技术分享,您的支持将鼓励我继续创作!