双网卡指定上网出口route路由DNS方法如下:
route -p add 10.130.0.0 mask 255.255.0.0 10.130.2.254
route delete 0.0.0.0
route -p add 0.0.0.0 mask 0.0.0.0 192.168.4.1
第一条命令route -p add 10.130.0.0 mask 255.255.0.0 10.130.2.254效果:
Network Address Netmask Gateway Address Metric
10.130.0.0 255.255.0.0 10.130.2.254 1
Network Address Netmask Gateway Address Metric
10.130.0.0 255.255.0.0 10.130.2.254 1
注意事项:如果255.255.255.0则无法ping通10.130.1.0网段(因为跨网段了)。
承接第一条命令,再输入第二条命令route -p add 0.0.0.0 mask 0.0.0.0 192.168.4.1后效果如下:
Persistent Routes:
Network Address Netmask Gateway Address Metric
10.130.0.0 255.255.0.0 10.130.2.254 1
0.0.0.0 0.0.0.0 192.168.4.1 1
原理:
如果访问10.130网段的话,就先走第一条route -p add 10.130.0.0 mask 255.255.0.0 10.130.2.254命令所指定的route路由,除此以外的访问,都走0.0.0.0这条路由,命令就是route -p add 0.0.0.0 mask 0.0.0.0 192.168.4.1。它的参数-p是永久保存到route里面,重启电脑也不会丢失,重启电脑也不需要两次输入这两条命令。
使用以上命令后查看route -p add 0.0.0.0 mask 0.0.0.0 192.168.4.1状态如下:
(C) 版权所有 1985-2003 Microsoft Corp.
C:\Documents and Settings\wsadmin1>route print
IPv4 Route Table
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x10003 ...54 e6 fc 01 ec bf ...... Atheros 11G USB Wireless Network Adapter - V
irtual Machine Network Services Driver
0x10004 ...00 e0 b1 07 5b 38 ...... Marvell Yukon 88E8040 Family PCI-E Fast Ethe
rnet Controller - Virtual Machine Network Services Driver
===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.9.1 192.168.9.8 25
10.130.0.0 255.255.0.0 10.130.2.196 10.130.2.196 1
10.130.2.0 255.255.255.0 10.130.2.196 10.130.2.196 20
10.130.2.196 255.255.255.255 127.0.0.1 127.0.0.1 20
10.255.255.255 255.255.255.255 10.130.2.196 10.130.2.196 20
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.9.0 255.255.255.0 192.168.9.8 192.168.9.8 25
192.168.9.8 255.255.255.255 127.0.0.1 127.0.0.1 25
192.168.9.255 255.255.255.255 192.168.9.8 192.168.9.8 25
224.0.0.0 240.0.0.0 10.130.2.196 10.130.2.196 20
224.0.0.0 240.0.0.0 192.168.9.8 192.168.9.8 25
255.255.255.255 255.255.255.255 10.130.2.196 10.130.2.196 1
255.255.255.255 255.255.255.255 192.168.9.8 192.168.9.8 1
Default Gateway: 192.168.9.1
===========================================================================
Persistent Routes:
Network Address Netmask Gateway Address Metric
10.130.0.0 255.255.0.0 10.130.2.196 1
0.0.0.0 0.0.0.0 192.168.9.1 1
C:\Documents and Settings\wsadmin1>
未使用前,不会有
Persistent Routes:
Network Address Netmask Gateway Address Metric
10.130.0.0 255.255.0.0 10.130.2.196 1
0.0.0.0 0.0.0.0 192.168.9.1 1
以上,请知悉。
The end.