sanyk's Blog

Happy coding

route man 手册页的详细中文翻译

原文地址
=========
以下是本文档完整版本地址:http://sanyk.is-programmer.com/posts/15488
(nt: 出现这一提示是为了避免一些网络蜘蛛把文章分成几个页面给查看带来不悦)

 

中文版
========

ROUTE(8)                   Linux Programmer's Manual                  ROUTE(8)


名字
       route- 显示或修改IP 路由表

用法概览
       (nt: route 使用方式可分为IV种)

       (nt: 第I 种)
       route  [-CFvnee]

       (nt: 第II 种)
       route  [-v]  [-A  family]  add [-net|-host] target [netmask Nm] [gw Gw]
              [metric N] [mss M] [window W]  [irtt  I]  [reject]  [mod]  [dyn]
              [reinstate] [[dev] If]

       (nt: 第III 种)
       route  [-v]  [-A  family]  del [-net|-host] target [gw Gw] [netmask Nm]
              [metric N] [[dev] If]

       (nt: 第IV 种)
       route  [-V] [--version] [-h] [--help]

描述
       Route 操作内核的IP 路由表. 其主要作用为: 当通过ifconfig 配置好一个
       接口后, 我们可以设置通过此接口到特定主机以及网络的静态路由条目.

       如果add 或者 del 选项被指定, route 会修改路由表. 对于其他的选项,
       route 只是显示当前路由表中的信息.

选项
       -A family
              使用由family 指定的地址族(比如, 'inet'; 对于family 可选值的完整列表
              可通过命令route --help 来得到.
              如inet,inet6,ax25,netrom,ipx, ddp,x25. 每种含义另需补充)

       -F     设置route 基于内核的FIB(转发规则信息数据库) 进行工作
              (nt: 打印中会提示‘内核IP路由表')

       -C     设置route 基于内核的路由信息缓存进行工作
              (nt: 打印中会提示'内核 IP 路由缓存')

       -v     设置route 打印详细的输出信息

       -n     显示数字表示的网络地址, 从而避免了主机名字的网络解析过程.
              这对分析为什么到指定名称服务器的路由失效很有用.

       -e     采用netstat 命令所使用的信息输出格式, 输出路由表信息. -ee
              将会详细输出表中每行路由条目的所有参数信息.

       del    删除一个路由条目

       add    添加一个路由条目

       target
              指定目标网络或者目标主机. 对于主机或网络IP 地址可以采用如下两种表达形式:
              点分十进制或者文本名字.

       -net   目标是一个网络(nt: 由target指定的目标)

       -host  目标是一个主机(nt: 由target指定的目标)

       netmask NM
              当添加一条针对网络的路由时, 使用NM 作为指定网络的网络掩码

       gw GW
              设置route路由数据包途经网关GW.(nt: 此处‘路由’可理解为‘传送’).
              注意: 由GW 指定的网关必须作为整个路由路径的第一站被到达,
              这通常意味着必须为GW 预先设置一条路由. 如果GW 直接使用本地
              主机上的网络接口的地址, 则route 会根据此地址所属的接口来实际
              投递该数据包. 这是与BSD惯例兼容的一个处理.

       metric M
              设置路由表中的metric 域的值为M(被守护路由器使用).
              (nt: 节点所对应metric 的含义可参考ifconfig 的metric 选项说明)

       mss M
              设置该路由节点上TCP的最大传输数据段(MSS)大小为M. 默认的大小是
              网络接口数据链路层所支持的MTU大小减去头部的一些大小(包括其上
              各层头,如ip 头, tcp头), 或者是通过mtu 路径搜寻得到的整条路径上的
              最小mtu值. 此项设置可用于mtu 路径搜寻失效时,强制通信对方发送
              小的TCP 数据包(通常, 是由于防火墙配置不正确, 从而阻碍了所需ICMP包
              的传输)

       window W
              设置该路由节点上TCP 的窗口大小为W 个字节. 此选项通常用于AX.25 的
              网络中, 此时驱动不能处理'对头拼接'的数据帧.(nt: 'back to back',
              '对头拼接' 的含义未知, 需补充)

       irtt I
              设置该路由节点上的初始往返时间为I 毫秒(1-12000). 通常在AX.25网络
              中会用到此选项. 如果忽略此选项, irtt的默认值为300毫秒(在
              RFC 1122中对此有描述)

       reject
              在路由表中安装一个阻塞路由条目, 这将使得对此路由条目的查询
              失效. 可用于在路由表中屏蔽指定网络的正常路由条目, 从而,
              对此网络会使用默认的路由条目. 注意, 这并不是
              防火墙(nt | rt: 可理解为,不能达到对指定网络的授权控制和完全屏蔽,
              因为默认路由条目还是可能到达目的网络)

       mod, dyn, reinstate
              在路由表中安装一个临时的或对原条目进行了修改的条目.
              此标志一般用于网络诊断的目的, 并且通常只在守护路由器会对其进行设置.
              (nt | rt: 此选项具体使用格式未知, 需补充, 等下看看具体的使用例子)

       dev If
              强制路由条目应用于指定的物理网络接口, 否则内核将按照自己的策略
              决定网络接口(比如通过检测已存在的一些路由条目所关联的接口,
              系统接口列表, 以及用户指定的物理网络接口). 在大多数网络中,
              我们不需要自己指定该选项.

              如果'dev If' 是命令行中最后一个选项, 那么dev 默认可以被省略.
              另外, 给路由条目指定的修饰符的出现的顺序可以任意(这些修饰符
              有metric, netmask, gw, dev)

示例
       route add -net 127.0.0.0 netmask 255.0.0.0 dev lo
              在路由表中添加一条关联回环接口lo的路由条目.
              该路由条目的目标是网络127.0.0.0, 对应的网络掩码为255.0.0.0(
              此处假设之前已通过ifconfig 对lo 进行了正确的配置)
              (nt: 此路由条目的含义可理解为, 对于发往
              网络127.0.0.0(掩码为255.0.0.0)的数据包将通过lo 接口投递出去)

       route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
              在路由表中添加一条关联本地接口eth0 的路由条目.
              该路由条目的目标是网络192.56.76.0, 对应的网络掩码为255.255.255.0.
              此处关键字'dev'可被省略(nt: 在'dev If'选项中对此已有相关描述)
              (nt: 此路由条目的含义可理解为, 对于发往
              网络192.56.76.0(掩码为255.255.255.0)的数据包将通过eth0 接口投递出去)

       route del default
              在路由表中删除当前的默认路由条目. 默认路由条目中的目标会以'default'字符串显示,
              或者'0.0.0.0'.
              网络192.56.76.0(掩码为255.255.255.0)的数据包将通过eth0 接口投递出去)

       route add default gw mango-gw
              添加一个默认路由条目(当其他路由条目匹配失效时会用到此默认路由条目).
              所有的数据包将通过网关mango-gw 发送出去. 而此路由条目所关联的物理
              网络接口取决于我们通过哪个接口到达'mango-gw'---即, 之前路由表中
              必须已经存在目标是'mango-gw' 的路由条目.

       route add ipx4 sl0
              在路由表中添加一条关联串行线路接口sl0 的路由条目, 该路由条目的
              目标主机为ipx4(此处假设, ipx4 是一个串行线路上的主机)

       route add -net 192.57.66.0 netmask 255.255.255.0 gw ipx4
              此命令将在路由表中添加一个目标网络为192.57.66.0(网络掩码为
              255.255.255.0)的路由条目. 该路由条目的网关为ipx4.
              (nt: 此路由条目的含义可理解为, 对于发往192.57.66.0(网络掩码为
              255.255.255.0)的数据包将通过网关ipx4发送出去, 即首先会发送
              到ipx4, 再由ipx4转发出去,而要发送到ipx4 会遵循'ipx4' 这个路由
              条目的设置-通过串口sl0 接口投递出去)

       route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
              此命令将在路由表中添加一个关联eth0 的路由条目.
              该路由条目的目标是所有目D类IP地址(多播地址).
              对于支持多播的内核, 这是一条常见的可用设置.

       route add -net 10.0.0.0 netmask 255.0.0.0 reject
              This  installs  a  rejecting  route  for  the  private   network
              "10.x.x.x."
              此命令将在路由表中添加一个目标网络为10.0.0.0(掩码为255.0.0.0)的阻塞路由条目.
              (nt | rt: 从而对发送到网络'10.x.x.x'的数据包会使用默认的路由条目)

输出
       内核路由表的输出被组织为以下几列数据:

       Destination
              该条目的目标网络或目标主机

       Gateway
              该条目的网关地址, 如果没有设置, 将用'*'号表示.

       Genmask
              该条目的网络掩码; 对于主机条目, 此列显示为'255.255.255.255',
              对于默认路由条目, 此列显示为'0.0.0.0'

       Flags  可能的标志取值包括
              U (该条目被使用)
              H (该条目目标是一个主机)
              G (该条目包含网关设置)
              R (对于动态安装的条目, 恢复该条目原来的设置)
              D (该条目属于动态安装的条目.(nt: daemon or redirect,未知, 需补充)
              M (该条目属于被修改的条目.(nt: daemon or redirect,未知, 需补充)
              A (该条目由addrconf 命令所添加)
              C (该条目属于缓存条目)
              ! (该条目属于阻塞条目)

       Metric
              到指定目标地址的'距离'(通常以'跃点'数来衡量这个距离). 最新的内核
              中已不再使用此参数, 而在守护路由中会用到此参数.

       Ref    对此路由条目的参考计数.(内核中不使用此参数)((nt: 具体含义未知, 需补充 ))

       Use
              对此路由条目的查询计数. 这取决于使用-F 还是 -C 参数, 前者表示此标志为
              不匹配的计数, 后者表示此标志为匹配的计数.

       Iface
              表示对应此路由条目的外发送数据包的投递接口.

       MSS
              表示对应此路由条目的TCP 连接默认最大数据段大小.

       Window
              此路由条目所对应TCP 连接的数据发送窗口大小.(nt: 里面的数据还未经接受端确认)

       irtt
              初始RTT(往返时间). 内核会根据irtt大小去猜测一些适合
              此路由条目的TCP 协议的参数以使得回应等待最短.

       HH (只适用于缓存路由表(-C 参数))
              表示ARP 条目或者缓存路由表条目中对此条目所对应硬件头缓冲(nt: 可理解为
              保存网络接口物理地址等信息的一个数据区)的引用计数.
              如果此条目所对应网络接口不需要物理地址(比如环回接口), 此字段值为-1.

       Arp (只适用于缓存路由表(-C 参数))
             此路由条目所对应接口的硬件地址是否是新近更新的值.


相关文件
       /proc/net/ipv6_route
       /proc/net/route
       /proc/net/rt_cache

       ifconfig(8), netstat(8), arp(8), rarp(8)


历史
       Linux 版本的route 程序最开始由Fred N. van  Kempen<waltje@uwalt.nl.mugnet.org>
       编写, 随后由Johannes 以及Linus Torvalds 为pl15 版本的内核加以修改.
       Alan Cox 在linux 1.1.22 内核版本中为route加入了mss以及 window列的输出.
       irtt 选项的支持以及此选项在netstat程序中的融入由Bernd Eckenfels完成.

作者
       route 目前由Phil Blundell  <Philip.Blundell@pobox.com>  以及
       Bernd Eckenfels <net-tools@lina.inka.de> 维护


net-tools                         2007-12-02                          ROUTE(8)
 

 

英文版

========

ROUTE(8)                                   Linux Programmer's Manual                                   ROUTE(8)



NAME
       route - show / manipulate the IP routing table

SYNOPSIS
       route [-CFvnee]

       route  [-v] [-A family] add [-net|-host] target [netmask Nm] [gw Gw] [metric N] [mss M] [window W] [irtt
              I] [reject] [mod] [dyn] [reinstate] [[dev] If]

       route  [-v] [-A family] del [-net|-host] target [gw Gw] [netmask Nm] [metric N] [[dev] If]

       route  [-V] [--version] [-h] [--help]

DESCRIPTION
       Route manipulates the kernel's IP routing tables.  Its primary use is to set up static  routes  to  spe-
       cific hosts or networks via an interface after it has been configured with the ifconfig(8) program.

       When  the  add or del options are used, route modifies the routing tables.  Without these options, route
       displays the current contents of the routing tables.


OPTIONS
       -A family
              use the specified address family (eg `inet'; use `route --help' for a full list).


       -F     operate on the kernel's FIB (Forwarding Information Base) routing table.  This is the default.

       -C     operate on the kernel's routing cache.


       -v     select verbose operation.

       -n     show numerical addresses instead of trying to determine symbolic host names. This  is  useful  if
              you are trying to determine why the route to your nameserver has vanished.

       -e     use  netstat(8)-format for displaying the routing table.  -ee will generate a very long line with
              all parameters from the routing table.


       del    delete a route.

       add    add a new route.

       target the destination network or host. You can provide IP addresses in dotted decimal  or  host/network
              names.

       -net   the target is a network.

       -host  the target is a host.

       netmask NM
              when adding a network route, the netmask to be used.

       gw GW  route  packets  via a gateway.  NOTE: The specified gateway must be reachable first. This usually
              means that you have to set up a static route to  the  gateway  beforehand.  If  you  specify  the
              address  of  one of your local interfaces, it will be used to decide about the interface to which
              the packets should be routed to. This is a BSDism compatibility hack.

       metric M
              set the metric field in the routing table (used by routing daemons) to M.

       mss M  set the TCP Maximum Segment Size (MSS) for connections over this route to M bytes.   The  default
              is  the  device  MTU minus headers, or a lower MTU when path mtu discovery occurred. This setting
              can be used to force smaller TCP packets on the other end when path mtu discovery does  not  work
              (usually because of misconfigured firewalls that block ICMP Fragmentation Needed)

       window W
              set  the  TCP window size for connections over this route to W bytes. This is typically only used
              on AX.25 networks and with drivers unable to handle back to back frames.

       irtt I set the initial round trip time (irtt) for TCP connections over  this  route  to  I  milliseconds
              (1-12000).  This  is  typically  only  used on AX.25 networks. If omitted the RFC 1122 default of
              300ms is used.

       reject install a blocking route, which will force a route lookup to fail.  This is for example  used  to
              mask out networks before using the default route.  This is NOT for firewalling.

       mod, dyn, reinstate
              install  a  dynamic or modified route. These flags are for diagnostic purposes, and are generally
              only set by routing daemons.

       dev If force the route to be associated with the specified device, as the kernel will otherwise  try  to
              determine  the  device on its own (by checking already existing routes and device specifications,
              and where the route is added to). In most normal networks you won't need this.

              If dev If is the last option on the command line, the word  dev  may  be  omitted,  as  it's  the
              default. Otherwise the order of the route modifiers (metric - netmask - gw - dev) doesn't matter.


EXAMPLES
       route add -net 127.0.0.0 netmask 255.0.0.0 dev lo
              adds the normal loopback entry, using netmask 255.0.0.0  and  associated  with  the  "lo"  device
              (assuming this device was previously set up correctly with ifconfig(8)).


       route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
              adds a route to the local network 192.56.76.x via "eth0".  The word "dev" can be omitted here.


       route del default
              deletes the current default route, which is labeled "default" or 0.0.0.0 in the destination field
              of the current routing table.


       route add default gw mango-gw
              adds a default route (which will be used if no other route  matches).   All  packets  using  this
              route will be gatewayed through "mango-gw". The device which will actually be used for that route
              depends on how we can reach "mango-gw" - the static route to "mango-gw" will have to  be  set  up
              before.


       route add ipx4 sl0
              Adds the route to the "ipx4" host via the SLIP interface (assuming that "ipx4" is the SLIP host).


       route add -net 192.57.66.0 netmask 255.255.255.0 gw ipx4
              This command adds the net "192.57.66.x" to be gatewayed through the  former  route  to  the  SLIP
              interface.


       route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
              This is an obscure one documented so people know how to do it. This sets all of the class D (mul-
              ticast) IP routes to go via "eth0". This is the correct normal configuration line with  a  multi-
              casting kernel.


       route add -net 10.0.0.0 netmask 255.0.0.0 reject
              This installs a rejecting route for the private network "10.x.x.x."



OUTPUT
       The output of the kernel routing table is organized in the following columns

       Destination
              The destination network or destination host.

       Gateway
              The gateway address or '*' if none set.

       Genmask
              The  netmask  for the destination net; '255.255.255.255' for a host destination and '0.0.0.0' for
              the default route.

       Flags  Possible flags include
              U (route is up)
              H (target is a host)
              G (use gateway)
              R (reinstate route for dynamic routing)
              D (dynamically installed by daemon or redirect)
              M (modified from routing daemon or redirect)
              A (installed by addrconf)
              C (cache entry)
              !  (reject route)

       Metric The 'distance' to the target (usually counted in hops). It is not used by recent kernels, but may
              be needed by routing daemons.

       Ref    Number of references to this route. (Not used in the Linux kernel.)

       Use    Count  of  lookups  for  the  route.  Depending on the use of -F and -C this will be either route
              cache misses (-F) or hits (-C).

       Iface  Interface to which packets for this route will be sent.

       MSS    Default maximum segment size for TCP connections over this route.

       Window Default window size for TCP connections over this route.

       irtt   Initial RTT (Round Trip Time). The kernel uses this to guess about the best TCP protocol  parame-
              ters without waiting on (possibly slow) answers.

       HH (cached only)
              The  number  of  ARP  entries  and  cached routes that refer to the hardware header cache for the
              cached route. This will be -1 if a hardware address is not needed for the interface of the cached
              route (e.g. lo).

       Arp (cached only)
              Whether or not the hardware address for the cached route is up to date.


FILES
       /proc/net/ipv6_route
       /proc/net/route
       /proc/net/rt_cache


SEE ALSO
       ifconfig(8), netstat(8), arp(8), rarp(8)


HISTORY
       Route  for  Linux  was  originally written by Fred N.  van Kempen, <waltje@uwalt.nl.mugnet.org> and then
       modified by Johannes Stille and Linus Torvalds for pl15. Alan Cox added the mss and window  options  for
       Linux 1.1.22. irtt support and merged with netstat from Bernd Eckenfels.

AUTHOR
       Currently   maintained   by   Phil   Blundell  <Philip.Blundell@pobox.com>  and  Bernd  Eckenfels  <net-
       tools@lina.inka.de>.



net-tools                                          2007-12-02                                          ROUTE(8)

 

符号约定
========

越少越好(目前只有一个):
nt:  即note的缩写, 表示翻译时的补充说明部分