華爲產品技術學習筆記之路由原理(一)

       路由器:路由器是一種典型的網絡鏈接設備,用來進行路由選擇和報文轉發。
路由器與它直接相連的網絡的跳數爲0,經過一臺路由器可達的網絡的跳數爲1.
      路由協議:路由器之間維護路由表的規則,用以發現路由,生成路由表,並引導報文轉發。
      路由器決策路由關鍵是路由表,轉發報文關鍵是FIB表(Forwarding Information Base)表。每一個路由器至少維護着一張路由表和一張FIB表。
      路由表中一般包含:
鏈路層協議發現的路由(接口路由或直連路由)
網絡管理員人工配置的靜態路由
動態路由協議主動發現的路由
 
FIB表指明分組到某網段或某主機應經過路由器的物理接口或邏輯接口發送,到達計劃路徑的下一個路由器,固然也能夠不通過路由器直達直接相連網絡中的主機。
一臺路由器保存着一張本地核心(管理)路由表,路由協議也維護着本身的路由表。即
本地核心路由表
      用來保護協議路由和決策優選路由,負責把優選路由下發到FIB,由FIB負責指導轉發。具體經過display ip routing-table,查看
各類路由協議的優先級和度量值選取路由。
協議路由表
     即協議主動發現的路由。路由協議能夠引入併發布其它協議生成的路由。
例如:查看路由表
< quidway>dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
        Destinations : 20       Routes : 20
Destination/Mask    Proto  Pre  Cost     Flags NextHop         Interface
  10.201.54.215/32  Static 60   0          RD  10.201.81.19    GigabitEthernet1/0/23
  10.201.57.128/27  Static 60   0          RD  10.201.81.19    GigabitEthernet1/0/23
    10.201.62.0/26  Static 60   0          RD  10.201.81.19    GigabitEthernet1/0/23
    10.201.63.4/32  Static 60   0          RD  10.201.81.19    GigabitEthernet1/0/23
   10.201.81.16/29  Direct 0    0           D  10.201.81.20    GigabitEthernet1/0/23
   10.201.81.20/32  Direct 0    0           D  127.0.0.1       InLoopBack0
   10.201.81.23/32  Direct 0    0           D  127.0.0.1       InLoopBack0
   10.201.81.24/30  Direct 0    0           D  10.201.81.25    Vlanif30
   10.201.81.25/32  Direct 0    0           D  127.0.0.1       InLoopBack0
   10.201.81.26/32  Direct 0    0           D  10.201.81.26    Vlanif30
   10.201.81.27/32  Direct 0    0           D  127.0.0.1       InLoopBack0
  10.201.93.241/32  Direct 0    0           D  127.0.0.1       InLoopBack0
  10.201.93.242/32  Static 60   0          RD  10.201.81.26    Vlanif30
      127.0.0.0/8   Direct 0    0           D  127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct 0    0           D  127.0.0.1       InLoopBack0
127.255.255.255/32  Direct 0    0           D  127.0.0.1       InLoopBack0
      138.1.1.1/32  Static 60   0          RD  10.201.81.19    GigabitEthernet1/0/23
      138.2.1.1/32  Static 60   0          RD  10.201.81.19    GigabitEthernet1/0/23
      138.7.1.1/32  Static 60   0          RD  10.201.81.19    GigabitEthernet1/0/23
255.255.255.255/32  Direct 0    0           D  127.0.0.1       InLoopBack0
解釋:
Route Flags:路由標記,R表示該路由是迭代路由,D表示該路由下發到FIB表。
Routing Tables:說明路由表是公網路由表仍是私網路由表。
Destinations:目的網絡或者主機的總數。
Routes:路由總數。
Destination/Mask:目的地址和子網掩碼。
Proto:協議,說明是直連、靜態仍是動態路由。
Pre:本條路由加入路由表的優先級。它包括前面所講的全部路由,加上優先級,優先級高(數值小)的即是當前的最佳路由。各協議的路由優先級以下表:
表1-1 路由協議及缺省時的路由優先級
路由協議或路由種類 相應路由的優先級
DIRECT                              0
OSPF                                10
IS-IS                                 15
STATIC                             60
RIP                                  100
OSPF ASE                        150
OSPF NSSA                      150
IBGP                                 255
EBGP                                255
注意:除直連路由(DIRECT)外,各類路由協議的優先級均可由用戶手工進行配置。
Cost:路由開銷。當到達同一目的地的多條路由具備相同的優先級時,它就派上用場了。路由開銷小的將成爲當前的最佳路由。
提醒:Pre用於不一樣路由協議間路由優先級的比較,cost即用於同一種路由協議內部不一樣路由優先級的比較。
Flags:路由標記,即路由表頭的Route Flags,表示路由信息所處狀態。
NextHop:下一跳地址。說明IP包通過的下一個路由器。
Interface:下一跳可達的出接口。說明IP包將從下一個路由器哪個接口轉發。
不過上面的路由表只是路由表簡表,它只顯示激活的路由,而完整的路由表還包括未激活的路由。能夠經過命令display ip routing-table verbose查看。
例如:
<quidway>dis ip routing-table verbose
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
        Destinations : 20       Routes : 27

Destination: 10.201.54.215/32
     Protocol: Static          Process ID: 0
   Preference: 60                    Cost: 0
      NextHop: 10.201.81.19     Neighbour: 0.0.0.0
        State: Active Adv GotQ        Age: 8d05h16m34s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: GigabitEthernet1/0/23
     TunnelID: 0x0                  Flags: RD
Destination: 10.201.54.215/32
     Protocol: Static          Process ID: 0
   Preference: 100                   Cost: 0
      NextHop: 10.201.81.26     Neighbour: 0.0.0.0
        State: Inactive Adv GotQ      Age: 8d05h16m34s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: Vlanif30
     TunnelID: 0x0                  Flags: R
Destination: 10.201.57.128/27
     Protocol: Static          Process ID: 0
   Preference: 60                    Cost: 0
      NextHop: 10.201.81.19     Neighbour: 0.0.0.0
        State: Active Adv GotQ        Age: 138d23h14m06s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: GigabitEthernet1/0/23
     TunnelID: 0x0                  Flags: RD
Destination: 10.201.57.128/27
     Protocol: Static          Process ID: 0
   Preference: 100                   Cost: 0
      NextHop: 10.201.81.26     Neighbour: 0.0.0.0
        State: Inactive Adv GotQ      Age: 138d23h14m06s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: Vlanif30
     TunnelID: 0x0                  Flags: R
Destination: 10.201.62.0/26              
     Protocol: Static          Process ID: 0
   Preference: 60                    Cost: 0
      NextHop: 10.201.81.19     Neighbour: 0.0.0.0
        State: Active Adv GotQ        Age: 138d23h14m05s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: GigabitEthernet1/0/23
     TunnelID: 0x0                  Flags: RD
Destination: 10.201.62.0/26
     Protocol: Static          Process ID: 0
   Preference: 100                   Cost: 0
      NextHop: 10.201.81.26     Neighbour: 0.0.0.0
        State: Inactive Adv GotQ      Age: 138d23h14m08s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: Vlanif30
     TunnelID: 0x0                  Flags: R
Destination: 10.201.63.4/32
     Protocol: Static          Process ID: 0
   Preference: 60                    Cost: 0
      NextHop: 10.201.81.19     Neighbour: 0.0.0.0
        State: Active Adv GotQ        Age: 140d23h35m45s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: GigabitEthernet1/0/23
     TunnelID: 0x0                  Flags: RD
Destination: 10.201.63.4/32
     Protocol: Static          Process ID: 0
   Preference: 100                   Cost: 0
      NextHop: 10.201.81.26     Neighbour: 0.0.0.0
        State: Inactive Adv GotQ      Age: 140d23h28m08s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: Vlanif30
     TunnelID: 0x0                  Flags: R
Destination: 10.201.81.16/29
     Protocol: Direct          Process ID: 0
   Preference: 0                     Cost: 0
      NextHop: 10.201.81.20     Neighbour: 0.0.0.0
        State: Active Adv             Age: 140d23h35m45s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: GigabitEthernet1/0/23
     TunnelID: 0x0                  Flags:  D
Destination: 10.201.81.20/32
     Protocol: Direct          Process ID: 0
   Preference: 0                     Cost: 0
      NextHop: 127.0.0.1        Neighbour: 0.0.0.0
        State: Active NoAdv           Age: 140d23h35m46s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: InLoopBack0
     TunnelID: 0x0                  Flags:  D
Destination: 10.201.81.23/32
     Protocol: Direct          Process ID: 0
   Preference: 0                     Cost: 0
      NextHop: 127.0.0.1        Neighbour: 0.0.0.0
        State: Active NoAdv           Age: 140d23h35m46s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: InLoopBack0
     TunnelID: 0x0                  Flags:  D
                                         
Destination: 10.201.81.24/30
     Protocol: Direct          Process ID: 0
   Preference: 0                     Cost: 0
      NextHop: 10.201.81.25     Neighbour: 0.0.0.0
        State: Active Adv             Age: 140d23h28m09s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: Vlanif30
     TunnelID: 0x0                  Flags:  D
Destination: 10.201.81.25/32
     Protocol: Direct          Process ID: 0
   Preference: 0                     Cost: 0
      NextHop: 127.0.0.1        Neighbour: 0.0.0.0
        State: Active NoAdv           Age: 140d23h28m09s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: InLoopBack0
     TunnelID: 0x0                  Flags:  D
Destination: 10.201.81.26/32
     Protocol: Direct          Process ID: 0
   Preference: 0                     Cost: 0
      NextHop: 10.201.81.26     Neighbour: 0.0.0.0
        State: Active NoAdv           Age: 140d23h28m05s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: Vlanif30
     TunnelID: 0x0                  Flags:  D
Destination: 10.201.81.27/32
     Protocol: Direct          Process ID: 0
   Preference: 0                     Cost: 0
      NextHop: 127.0.0.1        Neighbour: 0.0.0.0
        State: Active NoAdv           Age: 140d23h28m54s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: InLoopBack0
     TunnelID: 0x0                  Flags:  D
Destination: 10.201.93.241/32
     Protocol: Direct          Process ID: 0
   Preference: 0                     Cost: 0
      NextHop: 127.0.0.1        Neighbour: 0.0.0.0
        State: Active Adv             Age: 140d23h42m01s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: InLoopBack0
     TunnelID: 0x0                  Flags:  D
Destination: 10.201.93.242/32
     Protocol: Static          Process ID: 0
   Preference: 60                    Cost: 0
      NextHop: 10.201.81.26     Neighbour: 0.0.0.0
        State: Active Adv GotQ        Age: 138d23h13m26s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: Vlanif30
     TunnelID: 0x0                  Flags: RD
Destination: 127.0.0.0/8
     Protocol: Direct          Process ID: 0
   Preference: 0                     Cost: 0
      NextHop: 127.0.0.1        Neighbour: 0.0.0.0
        State: Active NoAdv           Age: 140d23h42m07s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: InLoopBack0
     TunnelID: 0x0                  Flags:  D
Destination: 127.0.0.1/32
     Protocol: Direct          Process ID: 0
   Preference: 0                     Cost: 0
      NextHop: 127.0.0.1        Neighbour: 0.0.0.0
        State: Active NoAdv           Age: 140d23h42m10s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: InLoopBack0
     TunnelID: 0x0                  Flags:  D
Destination: 127.255.255.255/32
     Protocol: Direct          Process ID: 0
   Preference: 0                     Cost: 0
      NextHop: 127.0.0.1        Neighbour: 0.0.0.0
        State: Active NoAdv           Age: 140d23h42m10s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: InLoopBack0
     TunnelID: 0x0                  Flags:  D
Destination: 138.1.1.1/32
     Protocol: Static          Process ID: 0
   Preference: 60                    Cost: 0
      NextHop: 10.201.81.19     Neighbour: 0.0.0.0
        State: Active Adv GotQ        Age: 140d23h36m37s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: GigabitEthernet1/0/23
     TunnelID: 0x0                  Flags: RD
Destination: 138.1.1.1/32
     Protocol: Static          Process ID: 0
   Preference: 100                   Cost: 0
      NextHop: 10.201.81.26     Neighbour: 0.0.0.0
        State: Inactive Adv GotQ      Age: 140d23h29m01s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: Vlanif30
     TunnelID: 0x0                  Flags: R
Destination: 138.2.1.1/32
     Protocol: Static          Process ID: 0
   Preference: 60                    Cost: 0
      NextHop: 10.201.81.19     Neighbour: 0.0.0.0
        State: Active Adv GotQ        Age: 140d23h36m38s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: GigabitEthernet1/0/23
     TunnelID: 0x0                  Flags: RD
Destination: 138.2.1.1/32
     Protocol: Static          Process ID: 0
   Preference: 100                   Cost: 0
      NextHop: 10.201.81.26     Neighbour: 0.0.0.0
        State: Inactive Adv GotQ      Age: 140d23h29m01s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: Vlanif30
     TunnelID: 0x0                  Flags: R
Destination: 138.7.1.1/32
     Protocol: Static          Process ID: 0
   Preference: 60                    Cost: 0
      NextHop: 10.201.81.19     Neighbour: 0.0.0.0
        State: Active Adv GotQ        Age: 140d23h36m38s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: GigabitEthernet1/0/23
     TunnelID: 0x0                  Flags: RD
Destination: 138.7.1.1/32
     Protocol: Static          Process ID: 0
   Preference: 100                   Cost: 0
      NextHop: 10.201.81.26     Neighbour: 0.0.0.0
        State: Inactive Adv GotQ      Age: 140d23h29m01s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: Vlanif30
     TunnelID: 0x0                  Flags: R
Destination: 255.255.255.255/32
     Protocol: Direct          Process ID: 0
   Preference: 0                     Cost: 0
      NextHop: 127.0.0.1        Neighbour: 0.0.0.0
        State: Active NoAdv           Age: 140d23h42m11s
          Tag: 0                 Priority: 0
        Label: NULL               QoSInfo: 0x0
 RelayNextHop: 0.0.0.0          Interface: InLoopBack0
     TunnelID: 0x0                  Flags:  D
解釋:
注意這裏的Routes比剛纔的多了,是由於將未激活的路由條數加進來了。此外,還多出其它一些項目:
Process ID:路由協議的進程號。
Neighbour:鄰居。
State:路由的狀態,包括有
Active:激活的路由
Invalid:無效的路由
Inactive:非激活的路由
NoAdv:不充許發佈的路由
Adv:能夠發佈的路由
Del:即將要刪除的路由
GotQ:迭代到下一跳及出接口的路由,或者迭代到隧道的路由
WatiQ:沒有迭代到下一跳及出接口的路由,或者迭代到隧道的路由
Stale:帶Stale標記的路由,在GR中使用
Age:路由有存活時間。
Tag:路由管理標識。
Priority:優先級。
Label:MPLS分配的標籤。
QoSInfo:QoS信息。
RelayNextHop:迭代下一跳。
Interface:迭代出接口。
Tunnel ID:隧道ID。
SecTunnel ID:備份隧道ID。
BkNextHop:備份出接口。
Route of Packet Load-balance:顯示逐包軟轉發查詢時所使用的路由的信息
前面說過,華爲路由器還有一個FIB負責指引報文轉發。路由表選擇出路由後,路由表就會將已經激活的路由下發到FIB中。因爲FIB表進行轉發。
FIB表根據匹配最長匹配原則。即查找FIB表時,報文的目的地址和FIB中各表項的掩碼進行「邏輯與」運算,將獲得的地址與FIB表項中的網絡地址匹配,並選擇最長匹配的FIB表項進行報文轉發。

 
 附註:關於迭代路由的解釋(摘抄網上的)
我對路由迭代的理解:
      一般路由的下一跳是路由器某個接口的同網段地址,可是存在這樣的情形:
     A ____B______D___E
       \____C_____/

    路由器A、B、C、D間運行IGP路由協議,而路由器E不參與,爲了使A能到達E,須要在A上配置靜態路由,A能夠經由B或者C到達D再到達E,那麼咱們能夠在A上配置到E的2條路由:
      E    下一跳B      
      E    下一跳C  (備用)
    
     當A到B的鏈路出現問題
     A __X_B______D___E
       \____C_____/
   
    下一跳到C的路由起做用了,能夠正常工做。
    可是若是是B-D的鏈路出問題怎麼辦呢?看下圖:
     A ____B__X___D___E
       \____C_____/
      A並不知道這一點,仍然將到E的報文向B轉發結果固然是不通了。
      解決的辦法就是在A上配置迭代路由
      E    下一跳D             A到E具體走B仍是走C取決於A到D是走B仍是走C,       而A到D具體是走B仍是走C則由IGP路由協議動態算出,這樣不管是A-B的鏈路出現問題仍是B-D的鏈路出現問題都不會影響A-E的轉發。       有人要問爲何不讓E也參與IGP不使用靜態路由不就不會出相似問題麼?       一、在真實的組網環境中極可能A\B\C\D屬於同一個管理區域,E屬於另外一個管理區域,互相之間不容許運行IGP路由協議。       二、A-D間可能採用了某種隧道技術,可能B/C根本就不知道E的存在,使用IGP路由協議也不能解決。
相關文章
相關標籤/搜索