免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3374 | 回复: 0
打印 上一主题 下一主题

win下的路由器配置 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-06-20 16:07 |只看该作者 |倒序浏览
使用 Route 命令行工具查看并编辑计算机的 IP 路由表。Route 命令和语法如下所示:route [-f] [-p] [Command][Destination] [mask Netmask] [Gateway] [metric Metric]] [if Interface]]-f 清除所有网关入口的路由表。如果该参数与某个命令组合使用,路由表将在运行命令前清除。  -p 与 add 命令一起使用时使路由具有永久性。 该参数与 add 命令一起使用时,将使路由在系统引导程序之间持久存在。默认情况下,系统重新启动时不保留路由。与 print 命令一起使用时,显示已注册的持久路由列表。忽略其他所有总是影响相应持久路由的命令。[color="#ff0000"]Command 指定您想运行的命令 (Add/Change/Delete/Print)。
[color="#ff0000"]路由类型:
有三种路由1.[color="#ff0000"]主机路由从一台主机映射一条到本地网络上的的其他主机上command format:route add -host destination_ip local_ip -interface interfaceeg:我们想为本地主机接口hme0(204.12.17.1)和另一台在相邻才C类网络上的主机(204.12.16.100)之间增加一条路由#route add -host 204.12.16.100 204.12.17.1 -interface hme02.[color="#ff0000"]网络路由允许数据包从本地主机传输到在本地网络的其他主机上增加一个到另一个网络的的直接路由command format:route add -net  destination_network_ip local_ip -netmask maskeg:如果我们要想为C类网掩码在本地主机(204.12.17.1)和我们上面指出的网络之间增加一条路由(204.12.16.0网络)我们可以使用如下的命令:#route add -net 204.12.16.0 204.12.17.1 -netmask 255.255.255.03.[color="#ff0000"]缺省路由将寻找一条路由的任务传送到一台路由器。RIP 和RDISC守护进程都可以使用缺省路由。command format:route add default hostname -interface interfaceeg:增加一条到本地路由器(204.54.56.1)的缺省路由,通常用在添加网关并马上生效#route add default 204.54.56.1 -interface hme1
[color="#ff0000"]Destination 指定该路由的网络目标。
[color="#ff0000"]mask Netmask 指定与网络目标相关的网络掩码(也被称作子网掩码)。如果没有指定,将使用 255.255.255.255  
[color="#ff0000"]Gateway 指定网络目标定义的地址集和子网掩码可以到达的前进或下一跃点 IP 地址。  
[color="#ff0000"]metric Metric 为路由指定一个整数成本值标(从 1 至 9999),当在路由表(与转发的数据包目标地址最匹配)的多个路由中进行选择时可以使用。
[color="#ff0000"]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
原文内容:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/route.mspx?mfr=true
RouteDisplays and modifies the entries in the local IP routing table. Used without parameters, route displays help.
Syntaxroute [-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_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes.
Command : Specifies the command you want to run. The following table lists valid commands.
CommandPurposeadd
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 theroute 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 systemroot\System32\Drivers\Etc 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 thesystemroot\system32\drivers\etc 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 routecommand 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
ExamplesTo 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 legendFormatMeaningItalic
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 ([])
Optional items
Between braces ({}); choices separated by pipe (|). Example: {even|odd}
Set of choices from which the user must choose only one
Courier font
Code or program output
Command-line reference A-Z
TCP/IP utilities and services

Top of page
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/66321/showart_1971639.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP