route add 行业应用

route add命令详解 /win2000/winxp/win2003

如果一台电脑有两个以上的网卡,而且需要同时使用,就需要在单机上通过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值代表开销,值越小越优先,缺省值为1(最优)。

route add -p 10.0.0.0 mask 255.0.0.0 192.168.0.254

p代表Persistent(持续,固定),上面的命令代表永久路由,禁用网卡、关机等操作都不会删除该路由。

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) - 数据包计划程序微型端口
0x10005 ...00 08 02 e5 79 6f ...... Intel(R) PRO/100 VM Network Connection - 数据包计划程序微型端口
0x20004 ...00 05 9a 3c 78 00 ...... Cisco Systems VPN Adapter - 数据包计划程序微型端口===========================================================================
===========================================================================
Active Routes:
Network Destination        Netmask              Gateway           Interface    Metric

路由表明细………

……

                 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

一般来说,用route add命令不需要加if参数,如果发现用route add命令增加路由后,路由选择的接口不对,就需要选择if参数。

举例:

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] 查看路由表项中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

猜你喜欢

转载自liyx985.iteye.com/blog/1971966
Add