Windows系统修改本地路由表 XP 7 Server2003 Server2008
(2012-07-24 12:43:27)
标签:
windows修改本地路由表xp7server2003server2008 |
分类: Windows |
XP
Server2003下,在CMD输入:route命令
[MASK
netmask] [gateway] [METRIC metric]
[IF interface]
-f
Clears the
routing tables of all gateway entries. If this
is
used in conjunction with one
of the commands, the tables are
cleared prior to running the
command.
-p
When used with the ADD command, makes a route
persistent across
boots of the system. By
default, routes are not preserved
when the system is restarted.
Ignored for all other commands,
which always affect the
appropriate persistent routes. This
option is not supported in
Windows 95.
command
One of these:
PRINT
Prints a
route
ADD
Adds
a route
DELETE
Deletes a route
CHANGE
Modifies an existing
route
destination Specifies the
host.
MASK
Specifies that the next
parameter is the 'netmask' value.
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.
Invalid MASK generates
an error, that is when (DEST & MASK) != DEST.
Example>
route ADD 157.0.0.0 MASK 155.0.0.0 157.55.80.1 IF 1
The route addition failed: The specified mask
parameter is invalid
(Destination & Mask) !=
Destination.
> route
PRINT
> route
ADD 157.0.0.0 MASK 255.0.0.0 157.55.80.1 METRIC 3
IF 2
destination^
^mask
^gateway
metric^
^
Interface^
If IF
is not given, it tries to find the best interface for a given
gateway.
> route
PRINT
> route
PRINT 157*
.... Only prints those
matching 157*
> route
CHANGE 157.0.0.0 MASK 255.0.0.0 157.55.80.5 METRIC 2 IF 2
CHANGE is used to modify gateway and/or metric only.
> route
PRINT
> route
DELETE 157.0.0.0
> route
PRINT
[MASK
netmask] [gateway] [METRIC metric]
[IF interface]
-f
清除所有网关项的路由表。如果与某个
命令结合使用,在运行该命令前,
应清除路由表。
-p
与 ADD
命令结合使用时,将路由设置为
在系统引导期间保持不变。默认情况下,重新启动系统时,
不保存路由。忽略所有其他命令,
这始终会影响相应的永久路由。Windows 95
不支持此选项。
-4
强制使用
IPv4。
-6
强制使用
IPv6。
command
其中之一:
PRINT
打印路由
ADD
添加路由
DELETE
删除路由
CHANGE
修改现有路由
destination 指定主机。
MASK
指定下一个参数为“网络掩码”值。
netmask
指定此路由项的子网掩码值。
如果未指定,其默认设置为
255.255.255.255。
gateway
指定网关。
interface
指定路由的接口号码。
METRIC
指定跃点数,例如目标的成本。
Manipulates network routing tables.
ROUTE [-f] [-p] [command [destination]
All symbolic names used for destination are looked up in the
network database
file NETWORKS. The symbolic names for gateway are looked up in
the host name
database file HOSTS.
If the command is PRINT or DELETE. Destination or gateway can
be a wildcard,
(wildcard is specified as a star '*'), or the gateway argument
may be omitted.
If Dest contains a * or ?, it is treated as a shell pattern,
and only
matching destination routes are printed. The '*' matches any
string,
and '?' matches any one char. Examples: 157.*.1, 157.*, 127.*,
*224*.
Diagnostic Notes:
Examples:
IF参数为网络接口号,可以通过命令:arp -a获得。
实例说明:
显示路由表:
route print //显示IP路由表的完整内容
route print 192.* //显示 IP 路由表中以192.开始的路由
添加路由:
route add 0.0.0.0 mask 0.0.0.0 192.168.1.1 //默认路由
route add 192.168.88.0 mask 255.255.255.0 192.168.1.1
//目标网络192.168.88.0的网关为192.168.1.1
route -p add 192.168.88.0 mask 255.255.255.0
192.168.1.1 //-p代理此路由永久有效(永久路由存储在注册表中的位置是
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes)
route add 192.168.88.0 mask
255.255.255.0 192.168.1.1 METRIC 2
//METRIC代表此路由的度量值(代价)
route add 192.168.88.0 mask 255.255.255.0
192.168.1.1 IF 0x3
//为指定网络接口指定路由
删除路由:
route delete 192.168.88.0 mask 255.255.255.0
//删除目标网络192.168.88.0的路由
route
delete 192.* //删除目标网络以192.*开头的所有路由
修改路由:
route change 192.168.88.0 mask
255.255.255.0 192.168.1.2
//将目标网络192.168.88.0的网关改为192.168.1.2
route change 192.168.88.0 mask 255.255.255.0
192.168.1.1 METRIC 10 //修改METRIC此路由的度量值(代价)
Windows
7/Server2008,CMD输入:ROUTE
ROUTE [-f] [-p] [-4|-6] command [destination]
语法类似,增加了IPV6的支持。
在Windows7/Server2008请以管理员身份运行CMD!

加载中…