路由表構成簡介(Destination/Gateway/Genmask/Iface)

scm1911發表於2018-12-29

linux 路由表

路由表樣例

[root@centos6 ~]#route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.27.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
0.0.0.0         192.168.27.2    0.0.0.0         UG    0      0        0 eth0

路由表主要欄位說明

Destination: 目的地址,可以是主機地址、網路地址,常用的是網路地址
Gateway: 閘道器地址,所有未知地址都會找閘道器,有閘道器統一轉發,只有邊緣網路才會配置閘道器,並且直連網路不需要配置閘道器
Genmask:目的地址的子網掩碼
Iface: 介面,去往目的地址的網路路徑的出口(也就是從那個出口可以去往目的地址)

官方的原文

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 parameters 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.

路由器 R1 路由表

圖片名稱
網路ID 子網掩碼 介面 閘道器
10.0.0.0 255.0.0.0 1 -
172.16.0.0 255.255.0.0 2 -
192.168.0.0 255.255.255.0 2 172.16.0.2
192.168.100.0 255.255.255.0 2 172.16.0.2
0.0.0.0 0.0.0.0 2 172.16.0.2

路由器 R2 路由表

圖片名稱

連線網際網路的路由資訊省略
只有邊界路由才有 預設路由 0.0.0.0/0.0.0.0 gateway_ip
R2 不是邊界路由,所以沒有預設路由
只有 R1 R3 才有預設路由,可以進行路由合併

網路ID 子網掩碼 介面 閘道器
10.0.0.0 255.0.0.0 3 172.16.0.1
172.16.0.0 255.255.0.0 3 -
192.168.0.0 255.255.255.0 4 -
192.168.100.0 255.255.255.0 4 192.168.0.2

路由器 R3 路由表

圖片名稱
網路ID 子網掩碼 介面 閘道器
10.0.0.0 255.0.0.0 5 192.168.0.1
172.16.0.0 255.255.0.0 5 192.168.0.1
192.168.0.0 255.255.255.0 5 -
192.168.100.0 255.255.255.0 6 -
0.0.0.0 0.0.0.0 5 192.168.0.1

本文連結:https://www.cnblogs.com/shichangming/p/10195389.html

相關文章