如果一臺(tái)電腦有兩個(gè)以上的網(wǎng)卡,而且需要同時(shí)使用,就需要在單機(jī)上通過(guò)router add命令增加路由。
route add命令格式如下:
route add destination mask mask gateway [metric metric] [if if-index]
舉例:
route add 10.0.0.0 mask 255.0.0.0 192.168.0.254
該命令將ip為10.x.x.x的路由都指到下一跳地址192.168.0.254上。
metric值代表開銷,值越小越優(yōu)先,缺省值為1(最優(yōu))。
route add -p 10.0.0.0 mask 255.0.0.0 192.168.0.254
p代表Persistent(持續(xù),固定),上面的命令代表永久路由,禁用網(wǎng)卡、關(guān)機(jī)等操作都不會(huì)刪除該路由。
if-index代表物理接口索引值,用route print命令可以查看:
C:\>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 50 ba 69 c1 c0 ...... D-Link DFE-530TX PCI Fast Ethernet Adapter (revB) - 數(shù)據(jù)包計(jì)劃程序微型端口
0x10005 ...00 08 02 e5 79 6f ...... Intel(R) PRO/100 VM Network Connection - 數(shù)據(jù)包計(jì)劃程序微型端口
0x20004 ...00 05 9a 3c 78 00 ...... Cisco Systems VPN Adapter - 數(shù)據(jù)包計(jì)劃程序微型端口===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
路由表明細(xì)………
……
16.0.0.0 255.0.0.0 192.168.0.254 192.168.0.1 1
……
===========================================================================
Persistent Routes:
Network Address Netmask Gateway Address Metric
10.0.0.0 255.0.0.0 192.168.0.254 1
一般來(lái)說(shuō),用route add命令不需要加if參數(shù),如果發(fā)現(xiàn)用route add命令增加路由后,路由選擇的接口不對(duì),就需要選擇if參數(shù)。
舉例:
route add -p 10.0.0.0 mask 255.0.0.0 192.168.0.254 metric 1 if 0x10005
附:
route print 查看所有路由
route print 10.[0.0.0] 查看路由表項(xiàng)中10.[0.0.0]的路由
route delete 刪除路由
route delete 10.0.0.0
route change 修改路由
route change [-p] 10.0.0.0 mask 255.0.0.0 192.168.0.254 metric 1 if 0x10004
聯(lián)系客服