网络基本命令-ROUTE

上一篇 / 下一篇  2009-03-25 11:59:15 / 个人分类:网络

一. 基础知识
Route是用来显示、人工添加和修改路由表项目的。我们知道我们在因特网上冲浪,并不是直接和我们要访问的主机通讯,而 是要通过许多的路由器。我们在用PING这个命令时就看出来了。我们就再举那个例子,比如我们要访问新浪网,它的信息传送到我们的本机上要经过11个路 由,但其实它也可以选择其它的路径来到我们本机,只是因为路由器有选择最短路径的能力所以它走现在这条路了,现在假如我们已经找到了一个其他的主机,让它 从肉鸡这条路上过来,我们就可以用route命令修改路由表项目,让它往我们指定的路径上过来。(写得太差劲,早到一段比较好的说明,又不想将此段删掉, 留下吧)
大多数主机一般都是驻留在只连接一台路由器的网段上。由于只有一台路由器,因此不存在使用哪一台路由器将数据报发表到远程计算机上去 的问题,该路由器的IP地址可作为该网段上所有计算机的缺省网关来输入。但是,当网络上拥有两个或多个路由器时,你就不一定想只依赖缺省网关了。实际上你 可能想让你的某些远程IP地址通过某个特定的路由器来传递,而其他的远程IP则通过另一个路由器来传递。在这种情况下,你需要相应的路由信息,这些信息储 存在路由表中,每个主机和每个路由器都配有自己独一无二的路由表。大多数路由器使用专门的路由协议来交换和动态更新路由器之间的路由表。但在有些情况下, 必须人工将项目添加到路由器和主机上的路由表中。Route就是用来显示、人工添加和修改路由表项目的。

usage:
ROUTE [-f] [-p] [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 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.(该参数与 add 命令一起使用时,将使路由在系统引导程序之间持久存在。默认情况下,系统重新启动时不保留路由。与 print 命令一起使用时,显示已注册的持久路由列表。忽略其他所有总是影响相应持久路由的命令。该选项在win95下不支持)
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.(指定与该路由条目关联的子网掩码。如果没有指定,将使用 255.255.255.255)
gateway Specifies gateway.(指定网关)
interface the interface number for the specified route.
METRIC specifies the metric, ie. 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 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.(名为 Networks 的网络数据库文件和名为 Hosts 的计算机名数据库文件中均引用全部 destination 或 gateway 使用的符号名称。如果命令是 print 或 delete,目标和网关还可以使用通配符,也可以省略网关参数)

二.实例

这个命令不太好贴出来,举例说明吧。

1.tracert -dhttp://www.sina.com.cn/
显示my host到http://www.sina.com.cn/所经过的所有路由途径。显示有途径11个路由。
2.显示路由表中的当前项:
C:\>route print
=======================================================================
Interface List
…………………………

和netstat -r显示路由信息的结果差不多。

3.把路由项目添加给路由表:route add
假设:新浪网的IP地址是61.145.113.87,我们到达它要经过11个路由,我们刚开始找到的那个主机,说明白点就是肉鸡的ip为xxx.xxx.xxx.xxx,子网掩码为255.255.255.224。我们就可以这样达到我们的目的:

route add 61.145.113.87 mask 255.255.255.224 xxx.xxx.xxx.xxx metric 11

4.修改数据的传输路由:route change
此参数能够改变数据的传输路由,但不能改变数据的目的地。
一样的道理,我们可自己选择一条更短的路径来访问。比如我们刚才让它绕到很远去访问新浪网,现在我又不想绕这么大的弯了。于是具体操作如下:

route add 61.145.113.87 mask 255.255.255.224 61.187.255.81 metric 4

四个路由当然比十一个路由要快得多,是不是?

5.从路由表中删除路由:route delete

t supported in Windows 95.(该参数与 add 命令一起使用时,将使路由在系统引导程序之间持久存在。默认情况下,系统重新启动时不保留路由。与 print 命令一起使用时,显示已注册的持久路由列表。忽略其他所有总是影响相应持久路由的命令。该选项在win95下不支持)
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.(指定与该路由条目关联的子网掩码。如果没有指定,将使用 255.255.255.255)
gateway Specifies gateway.(指定网关)
interface the interface number for the specified route.
METRIC specifies the metric, ie. cost for the destination.(指定跳数)

All symbolic names used

TAG: route ROUTE

 

评分:0

我来说两句

我的栏目

日历

« 2024-04-28  
 123456
78910111213
14151617181920
21222324252627
282930    

我的存档

数据统计

  • 访问量: 5099
  • 日志数: 9
  • 建立时间: 2009-03-24
  • 更新时间: 2009-03-25

RSS订阅

Open Toolbar