命令行大全

route

舞夕之 发表于 2020-06-28 16:01浏览次数:

Route命令用于手动配置路由表中的路由。

查看英文版

目录:

1 route 运行系统环境

2 route 语法

3 route 示例

route 运行系统环境

Windows 95

Windows 98

Windows xp

Windows vista

Windows 2000

Windows 7

Windows 8

Windows 10

Windows ME

route 语法

WindowsVista及以后的语法
ROUTE [-f] [-p] [-4|-6] command [destination] [MASK netmask] [gateway] [METRIC metric] [IF interface]
-f 清除所有网关条目的路由表。如果这与其中一个命令一起使用,则在运行该命令之前将清除这些表。
-p 当与ADD命令一起使用时,它将使路由在系统的各个靴子之间保持不变。 缺省情况下,系统重启时不保留路由。 与PRINT命令一起使用时,它显示已注册的持久路由的列表。 -p命令将被所有其他命令忽略,这将始终影响适当的持久性路由。 Windows'95不支持该选项。命令
-4 强制使用IPv4。
-6 强制使用IPv6。
command 其中之一是:

PRINT 打印路线。
ADD 添加路由。
DELETE 删除路由。
CHANGE 修改现有的路由目的地。

destination 指定主机。
MASK 指定下一个参数是“netmask”值。
netmask 指定子网mask此路由条目的值。如果未指定,则默认为255.255.255.255。
gateway 指定网关。
interface 指定路由的接口号。
METRIC 指定指标,即目标位置的费用。

所有用于目标的符号名称都在网络数据库文件网络中查找。网关的符号名称在主机名数据库文件主机。

如果命令是PRINT或DELETE,则目标或网关可以是通配符(通配符指定为星号'*'),或者可以省略gateway参数。

如果目标包含*或?,则将其视为SHELL模式,并且仅打印匹配的目标路由。 “ *”匹配任何字符串,而“?” 匹配任何一个字符。 例如:157。*。1、157。*,127。*,* 224 *。

只有在PRINT命令中才允许模式匹配。
诊断说明:
无效的MASK会生成错误,即(DEST&MASK)!= DEST。
示例>路由ADD 157.0.0.0 MASK 155.0.0.0 157.55.80.1 IF 1

路由添加失败:指定的mask参数无效。
(Destination & Mask) != Destination.

Windows XP和早期语法
ROUTE [-f] [-p] command [destination] [MASK netmask] [gateway] [METRIC metric] [IF interface]
-f 清除所有网关条目的路由表。如果这与其中一个命令一起使用,则在运行该命令之前将清除这些表。
-p 当与add命令一起使用时,它会使路由在系统的引导下持久存在。默认情况下,重新启动系统时不保留路由。当与print命令一起使用时,它将显示已注册的持久性路由列表。 对于所有其他命令,将忽略-p命令,这始终会影响相应的持久性路由。 Windows'95不支持该选项。
commnd 其中之一是:

PRINT 打印路线。
ADD 添加一条路线。
DELETE 删除路线。
CHANGE 修改现有的路线目的地。

destination 指定主机。
MASK 指定下一个参数是“ netmask”值。
netmask 指定此路由条目的子网mask值。 如果未指定,则默认为255.255.255.255。
gateway 指定网关
interface 指定路由的接口号。
METRIC 指定指标,即目标位置的费用。

所有用于目标的符号名称都在网络数据库文件网络中查找。网关的符号名在主机名数据库文件主机中查找。

如果命令是PRINT或DELETE,则目标或网关可以是通配符(通配符指定为星号'*'),或者可以省略gateway参数。

如果目标包含*或?,则将其视为SHELL模式,并且仅打印匹配的目标路由。 “ *”匹配任何字符串,而“?” 匹配任何一个字符。 例如:157。*。1、157。*,127。*,* 224 *。

诊断说明:
无效的MASK会生成错误,即(DEST&MASK)!= DEST。
示例>路由ADD 157.0.0.0 MASK 155.0.0.0 157.55.80.1 IF 1
路由添加失败:指定的mask参数无效。

(Destination & Mask) != Destination.

Windows Vista and later syntax
ROUTE [-f] [-p] [-4|-6] command [destination] [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 before running the command.
-p When used with the ADD command, it makes a route persistent across boots of the system. By default, routes are not preserved when the system is restarted. When used with the PRINT command, it displays the list of registered persistent routes. the -p command is ignored for all other commands, which always affect the appropriate persistent routes. This option is not supported Windows'95. command
-4 Force using IPv4.
-6 Force using IPv6.
command One of these:

PRINT Prints a route.
ADD Adds a route.
DELETE Deletes a route.
CHANGE Modifies an existing route destination.

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 a gateway.
interface The interface number for the specified route.
METRIC Specifies the metric, i.e., the cost for the 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 hostname database file HOSTS.

If the command is PRINT or DELETE the 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*.

Pattern match is only allowed in PRINT command.
Diagnostic Notes:
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.

Windows XP and earlier syntax
ROUTE [-f] [-p] command [destination] [MASK netmask] [gateway] [METRIC metric] [IF interface]
-f Clears the routing tables of all the gateway entries. If this is used in conjunction with one of the commands, the tables are cleared before running the command.
-p When used with the ADD command, it makes a route persistent across boots of the system. By default, routes are not preserved when the system is restarted. When used with the PRINT command, it displays the list of registered persistent routes. The -p command is ignored for all other commands, which always affect the appropriate persistent routes. This option is not supported Windows'95.
command One of these:

PRINT Prints a route.
ADD Adds a route.
DELETE Deletes a route.
CHANGE Modifies an existing route destination.

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 a gateway.
interface The interface number for the specified route.
METRIC Specifies the metric, i.e., the cost for the 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 hostname database file HOSTS.

If the command is PRINT or DELETE, the 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's 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:
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 示例

> route PRINT
rout ADD 157.0.0.0    MASK 255.0.0.0   157.55.80.1   METRIC 3  IF2
     ^destination     ^mask             ^gateway     ^metric   ^interface

如果未指定IF,它会尝试查找网关的最佳接口。

> route PRINT
> route PRINT 157* .... Only prints those matching 157*
> route DELETE 157.0.0.0
> route PRINT

一种使用方法如下:您不能ping正在连接的服务器,但您知道IP地址是127.16.16.10。

> route PRINT
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 14 a4 c3 44 20 ...... Xircom CardBus Ethernet 10/100 Adapter
0x3 ...00 b0 d0 43 55 a5 ...... 3Com EtherLink PCI
0x4 ...00 01 b0 8f 8f 80 ...... NdisWan Adapter
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 127.16.8.14 127.16.8.14 1
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
127.16.0.0 255.255.0.0 127.16.8.14 127.16.8.14 1
127.16.8.14 255.255.255.255 127.0.0.1 127.0.0.1 1
192.168.50.0 255.255.255.0 192.168.50.65 192.168.50.65 2
192.168.50.65 255.255.255.255 127.0.0.1 127.0.0.1 1
192.168.50.255 255.255.255.255 192.168.50.65 192.168.50.65 1
224.0.0.0 224.0.0.0 127.16.8.14 127.16.8.14 1
224.0.0.0 224.0.0.0 192.168.50.65 192.168.50.65 1
255.255.255.255 255.255.255.255 192.168.50.65 192.168.50.65 1

请注意,当前IP的网关没有通向255.255.255.0,因此必须添加。现在输入以下命令。

> route ADD 127.16.0.0 MASK 255.255.255.0METRIC 1

接下来,输入以下命令:

> route print
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 127.16.8.14 127.16.8.14 1
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
127.16.0.0 255.255.0.0 127.16.8.14 127.16.8.14 1
** 127.16.0.0 255.255.255.0 127.16.8.14 127.16.8.14 1
127.16.8.14 255.255.255.255 127.0.0.1 127.0.0.1 1
192.168.50.0 255.255.255.0 192.168.50.65 192.168.50.65 2
192.168.50.65 255.255.255.255 127.0.0.1 127.0.0.1 1
192.168.50.255 255.255.255.255 192.168.50.65 192.168.50.65 1
224.0.0.0 224.0.0.0 127.16.8.14 127.16.8.14 1
224.0.0.0 224.0.0.0 192.168.50.65 192.168.50.65 1
255.255.255.255 255.255.255.255 192.168.50.65 192.168.50.65 1

请注意,**IP地址为我提供了默认网关。

> route PRINT
rout ADD 157.0.0.0    MASK 255.0.0.0   157.55.80.1   METRIC 3  IF2
     ^destination     ^mask             ^gateway     ^metric   ^interface

When IF is not given, it tries to find the best interface for the gateway.

> route PRINT
> route PRINT 157* .... Only prints those matching 157*
> route DELETE 157.0.0.0
> route PRINT

One way to use this would be as follows: You can't ping the server that you are connecting to, but you know the IP address to be 127.16.16.10.

> route PRINT
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 14 a4 c3 44 20 ...... Xircom CardBus Ethernet 10/100 Adapter
0x3 ...00 b0 d0 43 55 a5 ...... 3Com EtherLink PCI
0x4 ...00 01 b0 8f 8f 80 ...... NdisWan Adapter
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 127.16.8.14 127.16.8.14 1
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
127.16.0.0 255.255.0.0 127.16.8.14 127.16.8.14 1
127.16.8.14 255.255.255.255 127.0.0.1 127.0.0.1 1
192.168.50.0 255.255.255.0 192.168.50.65 192.168.50.65 2
192.168.50.65 255.255.255.255 127.0.0.1 127.0.0.1 1
192.168.50.255 255.255.255.255 192.168.50.65 192.168.50.65 1
224.0.0.0 224.0.0.0 127.16.8.14 127.16.8.14 1
224.0.0.0 224.0.0.0 192.168.50.65 192.168.50.65 1
255.255.255.255 255.255.255.255 192.168.50.65 192.168.50.65 1

Notice that no gateway for the current IP goes to 255.255.255.0, so it must be added. Now enter the following command.

> route ADD 127.16.0.0 MASK 255.255.255.0  METRIC 1

Next, enter the following command:

> route print
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 127.16.8.14 127.16.8.14 1
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
127.16.0.0 255.255.0.0 127.16.8.14 127.16.8.14 1
** 127.16.0.0 255.255.255.0 127.16.8.14 127.16.8.14 1
127.16.8.14 255.255.255.255 127.0.0.1 127.0.0.1 1
192.168.50.0 255.255.255.0 192.168.50.65 192.168.50.65 2
192.168.50.65 255.255.255.255 127.0.0.1 127.0.0.1 1
192.168.50.255 255.255.255.255 192.168.50.65 192.168.50.65 1
224.0.0.0 224.0.0.0 127.16.8.14 127.16.8.14 1
224.0.0.0 224.0.0.0 192.168.50.65 192.168.50.65 1
255.255.255.255 255.255.255.255 192.168.50.65 192.168.50.65 1

Notice the ** IP address gives me the default gateway.

查看英文版

查看中文版