2023年11月27日发(作者:)

ip route 命令的作用详解

屏蔽访问IP和域名

命令行下运行 route -p-P表示重启后生效) add destip MASK 255.255.255.255 127.0.0.1

(用你要屏蔽的IP地址替换destip)

可能会报错,但是可以用 route print(知识若不分享 实在没有意义 ) 看到它确

实加进去了

比如

route -p add 220.189.126.2 MASK 255.255.255.255 127.0.0.1

route -p add 220.189.126.2 MASK 255.255.255.255 127.0.0.1

恢复屏蔽IP

route delete 59.42.248.210 mask 255.255.255.255

?

屏蔽域名

windows/system32/drivers/etc/hosts

怎样屏蔽IP地址

通常情况下,使用防火墙来阻断因特网交通是最好的办法。但是,低端防火墙,比如Internet Connection

Firewall并不能过滤单个IP地址。有一个过滤单个IP地址的办法是调整电脑上的路由表。路由命令行工

具可以解决这个问题。这是一个较难使用的工 具。不懂路由知识而贸然调整可能会导致电脑与网络失去连

接。

下面这样的命令可以阻断与IP地址为220.189.126.2的通信:

route p add 220.189.126.2 MASK 255.255.255.255 192.168.1.0 METRIC 1 IF 2

需要根据你的计算机调整接口号码,目的地IP应改为本地网络上以前不存在的一个地址。像我前面所说

的,解决办法并不容易。

Route命令详解

在本地 IP 路由表中显示和修改条目。

语法

route [-f] [-p] [Command [Destination] [mask Netmask] [Gateway] [metric Metric]] [if Interface]]

参数

-f

清除所有不是主路由(网掩码为 255.255.255.255 的路由)、环回网络路由(目标为 127.0.0.0,网掩码

255.255.255.0 的路由)或多播路由(目标为 224.0.0.0,网掩码为 240.0.0.0 的路由)的条目的路

由表。如果它与命令之一(例如 addchange delete)结合使用,表会在运行命令之前清除。

-p

add 命令共同使用时,指定路由被添加到注册表并在启动 TCP/IP 协议的时候初始化 IP 路由表。默认

情况下,启动 TCP/IP 协议时不会保存添加的路由。与 print 命令一起使用时,则显示永久路由列表。所

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters PersistentRoutes

Command

指定要运行的命令。下表列出了有效的命令。 命令 目的

add 添加路由

change 更改现存路由

delete 删除路由

print 打印路由

Destination

指定路由的网络目标地址。目标地址可以是一个 IP 网络地址(其中网络地址的主机地址位设置为 0),

对于主机路由是 IP 地址,对于默认路由是 0.0.0.0

mask subnetmask

指定与网络目标地址相关联的网掩码(又称之为子网掩码)。子网掩码对于 IP 网络地址可以是一适当的

子网掩码,对于主机路由是 255.255.255.255 ,对于默认路由是 0.0.0.0。如果忽略,则使用子网掩码

255.255.255.255。定义路由时由于目标地址和子网掩码之间的关系,目标地址不能比它对应的子网掩码更

为详细。换句话说,如果子网掩码的一位 0,则目标地址中的对应位就不能设置为 1

Gateway

指定超过由网络目标和子网掩码定义的可达到的地址集的前一个或下一个跃点 IP 地址。对于本地连接的

子网路由,网关地址是分配给连接子网接口的 IP 地址。对于要经过一个或多个路由器才可用到的远程路

由,网关地址是一个分配给相邻路由器的、可直接达到的 IP 地址。

metric Metric

为路由指定所需跃点数的整数值(范围是 1 ~ 9999),它用来在路由表里的多个路由中选择与转发包中的

目标地址最为匹配的路由。所选的路由具有最少的跃点数。跃点数能够反映跃点的数量、路径的速度、路

径可靠性、路径吞吐量以及管理属性。

if Interface

指定目标可以到达的接口的接口索引。使用 route print 命令可以显示接口及其对应接口索引的列表。对

于接口索引可以使用十进制或十六进制的值对于十六进制值要在十六进制数的前面加上 0x忽略 if

数时,接口由网关地址确定。

/?

在命令提示符显示帮助。

注释

由表中 跃点数 一列的值较大是由于允许 TCP/IP 根据每个 LAN接口的 IP 地址、子网掩码和默认网

关的配置自动确定路由表中路由的跃点数造成的。默认启动的自动确定接口跃点数确定了每个接口的速

度,调整了每个接口的路由跃点数, 因此最快接口所创建的路由具有最低的跃点数。要删除大跃点数,请

在每个 LAN 连接的 TCP/IP 协议的高级属性中禁用自动确定接口跃点数。

如果在 systemrootSystem32DriversEtc 文件夹的本地网络文件中存在适当的条目,名称可以用于

Destination。只要名称可以通过“域名系统” (DNS) 查询这样的标准主机名解析技术分解为 IP 地址,

就可以将其用于 GatewayDNS 查询使用存储在 systemrootSystem32DriversEtc 文件夹下的本地主机

文件和 NetBIOS 名称解析。

如果是 print delete 命令可以忽略 Gateway 参数使用通配符来表示目标和网关Destination

值可以是由星号 (*) 指定的通配符。如果指定目标含有一个星号 (*) 或问号 (?),它被看作是通配符,

只打印或删除匹配的目标路由星号代表任意一字符序列问号代表任一字符例如 10.*.1, 192.168.*

127.* *224* 都是星号通配符的有效使用。

使用了无效的目标和子网掩码(网掩码)值的组合,会显示“Route:bad gateway address netmask”错误

消息。目标中有一位或多位设置为 1,而其在子网掩码中的对应位设置为 0 时会发生这个错误。可以通过

二进制表示法表示目标和子网掩码来检查这种情况。以二进制表示的子网掩码包括表示目标网络地址部分

的一连串的 1 和表示目标主机地址部分的一连串的 0 两个部分查看目标以确定目标的主机地址部分(由

子网掩码所定义)是否有些位设置成了 1

只有 Windows NT 4.0Windows 2000Windows Millennium Edition Windows XP route 命令支持

-p 参数。Windows 95 Windows 98 route 命令不支持该参数。

只有当网际协议 (TCP/IP) 协议在 网络连接中安装为网络适配器属性的组件时,该命令才可用。

范例

要显示 IP 路由表的完整内容,请键入:

route print

要显示 IP 路由表中以 10. 开始的路由,请键入:

route print 10.*

要添加默认网关地址为 192.168.12.1 的默认路由,请键入:

route add 0.0.0.0 mask 0.0.0.0 192.168.12.1

要添加目标为 10.41.0.0,子网掩码为 255.255.0.0,下一个跃点地址为 10.27.0.1 的路由,请键入:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1

要添加目标为 10.41.0.0子网掩码为 255.255.0.0下一个跃点地址为 10.27.0.1 的永久路由请键入:

route -p add 10.41.0.0 mask 255.255.0.0 10.27.0.1

要添加目标为 10.41.0.0子网掩码为 255.255.0.0下一个跃点地址为 10.27.0.1跃点数为 7 的路由,

请键入:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 metric 7(

)

要添加目标为 10.41.0.0,子网掩码为 255.255.0.0,下一个跃点地址为 10.27.0.1,接口索引为 0x3

路由,请键入:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 if 0x3

要删除目标为 10.41.0.0,子网掩码为 255.255.0.0 的路由,请键入:

route delete 10.41.0.0 mask 255.255.0.0

要删除 IP 路由表中以 10. 开始的所有路由,请键入:

route delete 10.*

要将目标为 10.41.0.0,子网掩码为 255.255.0.0 的路由的下一个跃点地址由 10.27.0.1 更改为

10.27.0.25,请键入:

route change 10.41.0.0 mask 255.255.0.0 10.27.0.25

route 的命令

routing ip add/delete/set/show interface 在指定接口上添加、删除、配置或显示常规 IP 路由设置。

routing ip add/delete/set/show filter 在指定接口上添加、删除、配置或显示 IP 数据包筛选器。

routing ip add/delete/show boundary 在指定接口上添加、删除或显示多播边界设置。

routing ip add/set ipiptunnel 添加或配置 IP 中的 IP 接口。

routing ip add/delete/set/show rtmroute 添加、配置或显示不持续的路由表管理器路由。

routing ip add/delete/set/show persistentroute 添加、删除、配置或显示持续路由。

routing ip add/delete/set/show preferenceforprotocol 添加、删除、配置或显示路由协议的优先级。

routing ip add/delete/set/show scope 添加、删除或显示多播作用域。

routing ip set/show loglevel 配置或显示全局 IP 记录等级。

routing ip show helper 显示 IP 的所有 Netsh 实用程序子环境。

routing ip show protocol 显示所有正在运行的 IP 路由协议。

routing ip show mfe 显示多播转发项。

routing ip show mfestats 显示多播转发项统计。

routing ip show boundarystats 显示 IP 多播边界。

routing ip show rtmdestinations 显示路由表管理器路由表中的目标。

routing ip show rtmroutes 显示路由表管理器路由表中的路由。

routing ip nat set/show global 配置或显示全局网络地址转换 (NAT) 设置。

routing ip nat add/delete/set/show interface 添加、删除、配置或显示指定接口的 NAT 设置。

routing ip nat add/delete addressrange NAT 接口公用地址池中添加或删除一个地址范围。

routing ip nat add/delete addressmapping 添加或删除 NAT 地址映射。

routing ip nat add/delete portmapping 添加或删除 NAT 端口映射。

routing ip autodhcp set/show global 配置或显示全局 DHCP 分配器参数。

routing ip autodhcp set/show interface 配置或显示指定接口的 DHCP 分配器设置。

routing ip autodhcp add/delete exclusion DHCP 分配器地址范围中添加或删除一个排除范围。

routing ip dnsproxy set/show global 配置或显示全局 DNS 代理参数。

routing ip dnsproxy set/show interface 配置或显示指定接口的 DNS 代理参数。

routing ip igmp set/show global 配置或显示 IGMP 全局设置。

routing ip igmp add/delete/set/show interface 在指定接口上添加、删除、配置或显示 IGMP

routing ip igmp add/delete staticgroup 添加或删除指定接口的静态多播组。

routing ip igmp show grouptable 显示 IGMP 主机组表。

routing ip igmp show ifstats 显示每个接口的 IGMP 统计。

routing ip igmp show iftable 显示每个接口的 IGMP 主机组。

routing ip igmp show proxygrouptable 显示 IGMP 代理接口的 IGMP 组表。

routing ip igmp show rasgrouptable 显示远程访问服务器所使用的 Internet 接口的组表。

routing ip ospf set/show global 配置或显示全局 OSPF 设置。

routing ip ospf add/delete/set/show interface 在指定接口上添加、删除、配置或显示 OSPF

routing ip ospf add/delete/set/show area 添加、删除、配置或显示 OSPF 区域。

routing ip ospf add/delete/show range 在指定的 OSPF 区域上添加、删除、配置或显示范围。

routing ip ospf add/delete/set/show virtif 添加、删除、配置或显示 OSPF 虚拟接口。

routing ip ospf add/delete/show neighbor 添加、删除、配置或显示 OSPF 邻居。

routing ip ospf add/delete/show protofilter 添加、删除、配置或显示 OSPF 外部路由的路由信息源。

routing ip ospf add/delete/show routefilter 添加、删除、配置或显示 OSPF 外部路由的路由筛选。

routing ip ospf show areastats 显示 OSPF 区域统计。

routing ip ospf show lsdb 显示 OSPF 链接状态数据库。

routing ip ospf show virtifstats 显示 OSPF 虚拟链接统计。

routing ip relay set global 配置“DHCP 中继代理程序”的全局设置。

routing ip relay add/delete/set interface 在指定接口上添加、删除或配置“DHCP 中继代理程序”设

置。

routing ip relay add/delete dhcpserver DHCP 服务器地址列表中添加或删除 DHCP 服务器的 IP

址。

routing ip relay show ifbinding 显示接口的 IP 地址绑定。

routing ip relay show ifconfig 显示每个接口的“DHCP 中继代理程序”配置。

routing ip relay show ifstats 显示每个接口的 DHCP 统计。

routing ip rip set/show global 配置 IP RIP 全局设置。

routing ip rip add/delete/set/show interface 在指定接口上添加或配置 IP RIP 设置。

routing ip rip add/delete peerfilter 添加或删除 RIP 对等筛选器。

routing ip rip add/delete acceptfilter 在接受的路由列表中添加或删除 RIP 路由筛选器。

routing ip rip add/delete announcefilter 在公布的路由列表中添加或删除 RIP 路由筛选器。

routing ip rip add/delete/show neighbor 添加或删除 RIP 邻居。

routing ip rip set/show flags 在指定接口上配置 IP RIP 高级设置。

routing ip rip show globalstats 显示全局 RIP 参数。

routing ip rip show ifbinding 显示接口的 IP 地址绑定。

routing ip rip show ifstats 显示每个接口的 RIP 统计。

IPX netsh 路由命令

routing ipx add/set staticroute IPX 路由表中添加或配置静态 IPX 路由。

routing ipx add/set staticservice SAP 服务表中添加或配置静态 SAP 服务。

routing ipx add/set filter 在指定的接口上添加或配置 IPX 数据包筛选器。

routing ipx add/set interface 在请求拨号接口上启用 IPX 路由,或在指定的接口上配置 IPX 设置。

routing ipx set global 配置全局 IPX 路由设置。

routing ipx rip add/set filter 添加和配置 RIP 路由筛选器。

routing ipx rip set global 配置全局 IPX RIP 设置。

routing ipx rip set interface 在指定接口上配置 IPX RIP 设置。

routing ipx sap add/set filter 添加或配置 SAP 服务筛选器。

routing ipx sap set global 配置全局 IPX SAP 设置。

routing ipx sap set interface 在指定接口上配置 IPX SAP 设置。

routing ipx netbios add nbname 将静态 NETBIOS 名称添加到 IPX NetBIOS 名称表中。

routing ipx netbios set interface 在指定接口上配置基于 IPX NetBIOS 设置。(知识若不分享

在没有意义 )

学习Windows网络命令之route命令小档案

route命令主要用来管理本机路由表,可以查看,添加、修改或删除路由表条目。该命令在win2000以上

操作系统都可使用。

命令格式如下:

ROUTE [-f] [-p] [command] [destination] [MASK netmask] [gateway] [METRIC metric] [IF interface]

带方括号的参数可以省略。

各参数含义如下:

Command:可以是print(列出当前路由表)delete(删除路由表条目)add(添加路由表条目)change(

改已有路由表条目)这些命令之一。

-f:清空所有路由表的网关条目。如果与某个route指令一块使用,会在执行该命令前先清空路由表。

-p:这个选项与add命令一块使用时用于添加永久的静态路由表条目。如果没有这个参数添加的路由表条

目在系统重启后会丢失。如果其它命令使用这个选项此选项会被忽略。因为其它命令对路由表的影响总是

永久的。在Windows 95系统的route命令不支持这个选项。

destinationgateway netmaskmetricinterface参数分别定义路由表条目中的目标IP段,使用

网关,子网掩码、度量值和网络界面。(知识若不分享 实在没有意义 )

在命令中可以用字符串符号来替代目标网络和网关的IP表示,对于用符号名表示的网络,系统会查找

networks IP(winxp

C:WINDOWSsystem32driversetc目录下)对于用符号名表示的网关系统会使用 HOSTS文件来对符号名

进行解析。

如果是printdelete命令,目标网络和网关可以包括通配符(*?),而且网关参数可以省略。

如果在目标网络定义中包含*?这时这些通配符会按其在命令行界面中的含义*代表多个任意字符而?

代表一个任意字符。例如这样157.*.1

注意:在添加或修改路由条目时,如果目标网络与网络掩码不符会产生错误,也即DEST & MASK) != DEST

时,会报错。

注意,这个命令的很多部分是可以省略的,比如网络界面常被省略。如果在添加或修改的路由条目中省略

网络界面参数,系统会自动使用到达指定网关最合适的网络界面。例如,add命令的完全写法可以如下:

route ADD 157.0.0.0 MASK 255.0.0.0 157.55.80.1 METRIC 3 IF 2

这条命令添加到达IP157.0.0.0掩码为255.0.0.0的目标网络的路由,指定网关为157.55.80.1,跳数

定义为3,使用网络界面2

route PRINT 157*

仅被出以157开头的目标网络的路由条目。

route DELETE 157.0.0.0(知识若不分享 实在没有意义 )

删除到达目标子网157.0.0.0的路由条目。

windows route命令详解

在一个网上查找到的Linux下的route很类似但有部分不一样汗死开始以为是linux下的route.

使用 Route 命令行工具查看并编辑计算机的 IP 路由表。Route 命令和语法如下所示:

route [-f] [-p] [Command][Destination] [mask Netmask] [Gateway] [metric Metric]] [if Interface]]

-f 清除所有网关入口的路由表。如果该参数与某个命令组合使用,路由表将在运行命令前清除。

-p add 命令一起使用时使路由具有永久性。 该参数与 add 命令一起使用时,将使路由在系统引导程

序之间持久存在。默认情况下,系统重新启动时不保留路由。与 print 命令一起使用时,显示已注册的持

久路由列表。

忽略其他所有总是影响相应持久路由的命令。

Command 指定您想运行的命令 (Add/Change/Delete/Print)

路由类型:

有三种路由

1.主机路由从一台主机映射一条到本地网络上的的其他主机上

command format:

route add -host destination_ip local_ip -interface interface

eg:

我们想为本地主机接口hme0(204.12.17.1)和另一台在相邻才C类网络上的主机(204.12.16.100)之间增加

一条路由

#route add -host 204.12.16.100 204.12.17.1 -interface hme0

2.网络路由允许数据包从本地主机传输到在本地网络的其他主机上

增加一个到另一个网络的的直接路由

command format:

route add -net destination_network_ip local_ip -netmask mask

eg:

我们C类网掩码在本地主机(204.12.17.1)们上指出之间增条路

(204.12.16.0网络)我们可以使用如下的命令:

#route add -net 204.12.16.0 204.12.17.1 -netmask 255.255.255.0

3.缺省路由将寻找一条路由的任务传送到一台路由器。RIP RDISC守护进程都可以使用缺省路由。

command format:

route add default hostname -interface interface

eg:增加一条到本地路由器(204.54.56.1)的缺省路由,通常用在添加网关并马上生效

#route add default 204.54.56.1 -interface hme1(

)

Destination 指定该路由的网络目标。

mask Netmask 指定网络目标的网掩码被称作掩码。如有指定使

255.255.255.255

Gateway 指定网络目标定义的地址集和子网掩码可以到达的前进或下一跃点 IP 地址。

metric Metric 为路由指定一个整数成本值标(从 1 9999),当在路由表(与转发的数据包目标地址最

匹配)的多个路由中进行选择时可以使用。

if Interface 为可以访问目标的接口指定接口索引。就是说发往甲的数据用接口A,发往乙的用接口B

这一条在一个网卡捆绑了多个同网段的IP时应用非常有效。比如你捆绑 *.1 *.2两个地址,你可以

指定某一条主机路由是用*.1发,某一条是用*.2发。不然,默认情况下,发往同一子网的都是用一个IP

发。

若要获得一个接口列表和它们相应的接口索引,使用 route print 命令的显示功能。可以使用十进制或十

六进制值进行接口索引。

/? 在命令提示符处显示帮助。

名为 Networks 的网络数据库文件和名为 Hosts 的计算机名数据库文件中均引用全部

destination gateway 使用的符号名称。如果命令是 print delete,目标和网关

还可以使用通配符,也可以省略网关参数。

示例

若要显示 IP 路由表的全部内容,请键入:

route print

若要显示以 10. 起始的 IP 路由表中的路由,请键入:

route print 10.*

若要添加带有 192.168.12.1 默认网关地址的默认路由,请键入:(知识若不分享 实在没有意义)

route add 0.0.0.0 mask 0.0.0.0 192.168.12.1

若要向带有 255.255.0.0 子网掩码和 10.27.0.1 下一跃点地址的 10.41.0.0 目标中添加一个路由请键

入:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1

若要向带有 255.255.0.0 子网掩码和 10.27.0.1 下一跃点地址的 10.41.0.0 目标中添加一个永久路

由,请键入:

route -p add 10.41.0.0 mask 255.255.0.0 10.27.0.1

若要向带有 255.255.0.0 子网掩码10.27.0.1 下一跃点地址且其成本值标为 7 10.41.0.0 目标中添

加一个路由,请键入:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 metric 7

若要向带有 255.255.0.0 子网掩码10.27.0.1 下一跃点地址且使用 0x3 接口索引的 10.41.0.0 目标中

添加一个路由,请键入:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 if 0x3

若要删除到带有 255.255.0.0 子网掩码的 10.41.0.0 目标的路由,请键入:

route delete 10.41.0.0 mask 255.255.0.0

若要删除以 10. 起始的 IP 路由表中的所有路由,请键入:

route delete 10.*

10.41.0.0 255.255.0.0 10.27.0.1

10.27.0.25,请键入:

route change 10.41.0.0 mask 255.255.0.0 10.27.0.25

原文内容:

/resources/documentation/windows/xp/all/proddocs/en-us/?mf

r=true(知识若不分享 实在没有意义 )

Route

Displays and modifies the entries in the local IP routing table. Used without parameters, route

displays help.

Syntax

route [-f] [-p] [Command [Destination] [mask Netmask] [Gateway] [metric Metric]] [if Interface]]

Top of page

Parameters

-f : Clears the routing table of all entries that are not host routes (routes with a netmask of

255.255.255.255), the loopback network route (routes with a destination of 127.0.0.0 and a netmask

of 255.0.0.0), or a multicast route (routes with a destination of 224.0.0.0 and a netmask of

240.0.0.0). If this is used in conjunction with one of the commands (such as add, change, or delete),

the table is cleared prior to running the command.

-p : When used with the add command, the specified route is added to the registry and is used

to initialize the IP routing table whenever the TCP/IP protocol is started. By default, added

routes are not preserved when the TCP/IP protocol is started. When used with the print command,

the list of persistent routes is displayed. This parameter is ignored for all other commands.

Persistent routes are stored in the registry location

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParametersPersistentRoutes.

Command : Specifies the command you want to run. The following table lists valid commands.

Command Purpose

add

Adds a route.

change

Modifies an existing route.

delete

Deletes a route or routes.

print

Prints a route or routes.

Destination : Specifies the network destination of the route. The destination can be an IP network

address (where the host bits of the network address are set to 0), an IP address for a host route,

or 0.0.0.0 for the default route.(知识若不分享 实在没有意义 )

mask Netmask : Specifies the netmask (also known as a subnet mask) associated with the network

destination. The subnet mask can be the appropriate subnet mask for an IP network address,

255.255.255.255 for a host route, or 0.0.0.0 for the default route. If omitted, the subnet mask

255.255.255.255 is used. Because of the relationship between the destination and the subnet mask

in defining routes, the destination cannot be more specific than its corresponding subnet mask.

In other words, there cannot be a bit set to 1 in the destination if the corresponding bit in

the subnet mask is a 0.

Gateway : Specifies the forwarding or next hop IP address over which the set of addresses defined

by the network destination and subnet mask are reachable. For locally attached subnet routes,

the gateway address is the IP address assigned to the interface that is attached to the subnet.

For remote routes, available across one or more routers, the gateway address is a directly

reachable IP address that is assigned to a neighboring router.

metric Metric : Specifies an integer cost metric (ranging from 1 to 9999) for the route, which

is used when choosing among multiple routes in the routing table that most closely match the

destination address of a packet being forwarded. The route with the lowest metric is chosen. The

metric can reflect the number of hops, the speed of the path, path reliability, path throughput,

or administrative properties.

if Interface : Specifies the interface index for the interface over which the destination is

reachable. For a list of interfaces and their corresponding interface indexes, use the display

of the route print command. You can use either decimal or hexadecimal values for the interface

index. For hexadecimal values, precede the hexadecimal number with 0x. When the if parameter is

omitted, the interface is determined from the gateway address.

/? : Displays help at the command prompt.

Top of page

Remarks

? Large values in the metric column of the routing table are the result of allowing TCP/IP to

automatically determine the metric for routes in the routing table based on the configuration

of IP address, subnet mask, and default gateway for each LAN interface. Automatic determination

of the interface metric, enabled by default, determines the speed of each interface and adjusts

the metrics of routes for each interface so that the fastest interface creates the routes with

the lowest metric. To remove the large metrics, disable the automatic determination of the

interface metric from the advanced properties of the TCP/IP protocol for each LAN connection.

? Names can be used for Destination if an appropriate entry exists in the local Networks file

stored in the systemrootSystem32DriversEtc folder. Names can be used for the gateway as long

as they can be resolved to an IP address through standard host name resolution techniques such

as Domain Name System (DNS) queries, use of the local Hosts file stored in the

systemrootsystem32driversetc folder, and NetBIOS name resolution.

? If the command is print or delete, the Gateway parameter can be omitted and wildcards can be

used for the destination and gateway. The Destination value can be a wildcard value specified

by an asterisk (*). If the destination specified contains an asterisk (*) or a question mark (?),

it is treated as a wildcard and only matching destination routes are printed or deleted. The

asterisk matches any string, and the question mark matches any single character. For example,

10.*.1, 192.168.*, 127.*, and *224* are all valid uses of the asterisk wildcard.

? Using an invalid combination of a destination and subnet mask (netmask) value displays a "Route:

bad gateway address netmask" error message. This error message appears when the destination

contains one or more bits set to 1 in bit locations where the corresponding subnet mask bit is

set to 0. To test this condition, express the destination and subnet mask using binary notation.

The subnet mask in binary notation consists of a series of 1 bits, representing the network address

portion of the destination, and a series of 0 bits, representing the host address portion of the

destination. Check to determine whether there are bits in the destination that are set to 1 for

the portion of the destination that is the host address (as defined by the subnet mask).

? The -p parameter is only supported on the route command for Windows NT 4.0, Windows 2000, Windows

Millennium Edition, and Windows XP. This parameter is not supported by the route command for

Windows 95 or Windows 98.(知识若不分享 实在没有意义 )

? This command is available only if the Internet Protocol (TCP/IP) protocol is installed as a

component in the properties of a network adapter in Network Connections

Top of page

Examples

To display the entire contents of the IP routing table, type:

route print

To display the routes in the IP routing table that begin with 10., type:

route print 10.*

To add a default route with the default gateway address of 192.168.12.1, type:

route add 0.0.0.0 mask 0.0.0.0 192.168.12.1

To add a route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0 and the next hop

address of 10.27.0.1, type:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1

To add a persistent route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0 and

the next hop address of 10.27.0.1, type:(知识若不分享 实在没有意义 )

route -p add 10.41.0.0 mask 255.255.0.0 10.27.0.1

To add a route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0, the next hop

address of 10.27.0.1, and the cost metric of 7, type:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 metric 7

To add a route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0, the next hop

address of 10.27.0.1, and using the interface index 0x3, type:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 if 0x3

To delete the route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0, type:

route delete 10.41.0.0 mask 255.255.0.0

To delete all routes in the IP routing table that begin with 10., type:

route delete 10.*

To change the next hop address of the route with the destination of 10.41.0.0 and the subnet mask

of 255.255.0.0 from 10.27.0.1 to 10.27.0.25, type:(知识若不分享 实在没有意义)

route change 10.41.0.0 mask 255.255.0.0 10.27.0.25

Top of page

Formatting legend

Format Meaning

Italic

Information that the user must supply

Bold

Elements that the user must type exactly as shown

Ellipsis (...)

Parameter that can be repeated several times in a command line

Between brackets ([])