路由概念、協議分類、路由信息三種來源及路由基本配置操作

1、路由概念

MAC地址與IP地址:

用來定位設備;

MAC地址爲物理地址,工作在數據鏈路層,IP地址爲邏輯地址,工作在網絡層;

路由:爲需要跨網絡轉發的數據包提供的路徑信息;

路由協議:路由器之間分享路由信息所需要遵循的標準;

路由表:路由條目的集合;

路由條目:記錄特定目的IP地址與轉發接口的某類表項;

在華爲設備上查看路由表,通過命令:display ip routing-table

Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 4        Routes : 4        

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

      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
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
  • Destination/Mask:目的網絡/掩碼;
  • Proto:路由來源與類型,如直連、靜態,通過路由協議獲取的;
  • Pre:路由協議的優先級;
  • Cost  :路由開銷;
  • Flags:路由標記R:表示路由是迭代路由,路由標記D:表示該路由成功下發到FIB表;
  • NextHop  :路由下一跳;
  •  Interface:輸出接口;

優先級:

優先級數值越小,路由來源越可靠;

管理員可以修改優先級值,除了直連路由外;

路由來源 路由優先級默認值
Direct(直連) 0
Static(靜態) 60
OSPF 10
RIP 100

路由度量值:

指的是去往某網絡的開銷值;

路由開銷值越小,路由越優;

2、路由協議分類

分類標準:是否通告子網掩碼信息

有類路由:發送路由更新信息時不攜帶子網掩碼。如:RIPv1

無類路由:發送路由更新信息時攜帶子網掩碼。如:RIPv2、OSPF

分類標準:適用範圍

內部網關(IGP):有AS內部傳遞的路由。如:RIPv1、RIPv2、OSPF

外部網關(EGP):有AS直接傳遞的路由。如:BGP

分類標準:路由算法

距離矢量:沒有全網路由拓撲信息,依靠鄰居傳聞計算路由;

鏈路狀態:擁有全網拓撲信息,依靠自身計算路由;

距離矢量路由協議:

路由以矢量(距離、方向)的方式被通告出去的,其中距離是根據度量來定義的,方向是根據下一跳路由器定義的。被認爲是“依照傳聞進行路由選擇”。 (如:RIPv1、RIPv2)

鏈路狀態路由協議:

鏈路狀態路由協議又稱爲 最短路徑優先協議,它建基於 Edsger Dijkstra 的 SPF(最短路徑優先)算法。

3、路由基本配置

(1)首先建立拓撲結構如下:

AR1配置信息:

\blacktriangle 進入系統視圖:system-view

<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]

\blacktriangle 配置設備名稱:sysname 名稱

[Huawei]sysname AR1
[AR1]

\blacktriangle  進入接口視圖:interface 接口類型 接口編號

[AR1]interface gigabitethernet 0/0/0
[AR1-GigabitEthernet0/0/0]

 在這裏瞭解一下接口常識:

(1)S口:是serial接口的意思,也叫高速異步串口,主要是連接廣域網的V.35線纜用的,說白了就是路由器和路由器連接時候用的,可以用命令設置帶寬,一般也就在10M、8M左右。

(2)F口:是FastEthernet接口,叫快速以太網口,主要連接以太網(局域網)用的,說白了就是連接交換機或電腦用的,用普通的雙絞線就可以連接,速率默認是100Mbps,可以用命令限速,但是不可能超過100Mbps。

(3)E口:是Ethernet接口,叫以太網接口,也是主要連接以太網(局域網)用的,也是用普通的雙絞線就可以連接,速率默認是10Mbps,現在新型的設備上已經把這個接口淘汰了。

另外,路由器上還有一個必不可少的接口是Console口,叫控制口,這個接口是用來調試路由器的。

另外有的路由器還有AUX接口,也是控制接口;

(4)G口:是千兆以太網接口,是連接以太網用的。

 \blacktriangle  配置IP地址:ip address ip地址 子網掩碼

[AR1-GigabitEthernet0/0/0]ip address 10.0.12.1 255.255.255.0

 \blacktriangle  保存

<AR1>save
  The current configuration will be written to the device. 
  Are you sure to continue? (y/n)[n]:y
  It will take several minutes to save configuration file, please wait.........
  Configuration file had been saved successfully
  Note: The configuration file will take effect after being activated
<AR1>

AR2配置信息:

The device is running!

<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR2
[AR2]interface gigabitethernet 0/0/0
[AR2-GigabitEthernet0/0/0]ip address 10.0.12.2 255.255.255.0
Apr  7 2020 15:13:08-08:00 AR2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
 on the interface GigabitEthernet0/0/0 has entered the UP state. 
[AR2-GigabitEthernet0/0/0]interface gigabitethernet 0/0/1
[AR2-GigabitEthernet0/0/1]ip address 10.0.23.2 255.255.255.0
Apr  7 2020 15:13:47-08:00 AR2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
 on the interface GigabitEthernet0/0/1 has entered the UP state. 
[AR2-GigabitEthernet0/0/1]
<AR2>save
  The current configuration will be written to the device. 
  Are you sure to continue? (y/n)[n]:y
  It will take several minutes to save configuration file, please wait........
  Configuration file had been saved successfully
  Note: The configuration file will take effect after being activated
<AR2>

AR3配置信息:

The device is running!

<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR3
[AR3]interface gigabitethernet 0/0/1
[AR3-GigabitEthernet0/0/1]ip address 10.0.23.3 255.255.255.0
[AR3-GigabitEthernet0/0/1]
Apr  7 2020 15:15:37-08:00 AR3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
 on the interface GigabitEthernet0/0/1 has entered the UP state. 
[AR3-GigabitEthernet0/0/1]
<AR3>save
  The current configuration will be written to the device. 
  Are you sure to continue? (y/n)[n]:y
  It will take several minutes to save configuration file, please wait.........
  Configuration file had been saved successfully
  Note: The configuration file will take effect after being activated
<AR3>

(2)測試直連鏈路的連通性

(AR1與AR2:成功)

<AR2>ping 10.0.12.1
  PING 10.0.12.1: 56  data bytes, press CTRL_C to break
    Reply from 10.0.12.1: bytes=56 Sequence=1 ttl=255 time=230 ms
    Reply from 10.0.12.1: bytes=56 Sequence=2 ttl=255 time=40 ms
    Reply from 10.0.12.1: bytes=56 Sequence=3 ttl=255 time=30 ms
    Reply from 10.0.12.1: bytes=56 Sequence=4 ttl=255 time=30 ms
    Reply from 10.0.12.1: bytes=56 Sequence=5 ttl=255 time=30 ms

  --- 10.0.12.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 30/72/230 ms

(AR2與AR3:成功)

<AR2>ping 10.0.23.3
  PING 10.0.23.3: 56  data bytes, press CTRL_C to break
    Reply from 10.0.23.3: bytes=56 Sequence=1 ttl=255 time=150 ms
    Reply from 10.0.23.3: bytes=56 Sequence=2 ttl=255 time=30 ms
    Reply from 10.0.23.3: bytes=56 Sequence=3 ttl=255 time=30 ms
    Reply from 10.0.23.3: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 10.0.23.3: bytes=56 Sequence=5 ttl=255 time=20 ms

  --- 10.0.23.3 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/50/150 ms

(3)測試AR1與AR3連通性

[AR1]ping 10.0.23.3
  PING 10.0.23.3: 56  data bytes, press CTRL_C to break
    Request time out
    Request time out
    Request time out
    Request time out
    Request time out

  --- 10.0.23.3 ping statistics ---
    5 packet(s) transmitted
    0 packet(s) received
    100.00% packet loss

  可以看出連通失敗;

  此時查看路由AR1中的路由表 [AR1]display ip routing-table :

[AR1]display ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 7        Routes : 7        

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

      10.0.12.0/24  Direct  0    0           D   10.0.12.1       GigabitEthernet
0/0/0
      10.0.12.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
    10.0.12.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
      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
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

  沒有發現到AR3的路由表,所以不能連通;

解決方法:

(1)配置靜態路由

   ip route-static IP地址 {子網掩碼|掩碼長度} {下一跳地址|接口類型 接口編號 [下一跳地址]}

   AR1配置:

[AR1]ip route-static 10.0.23.0 255.255.255.0 10.0.12.2

   AR3配置:

[AR3]ip route-static 10.0.12.0 255.255.255.0 10.0.23.2

  再次連通AR1與AR3:

[AR1]ping 10.0.23.3
  PING 10.0.23.3: 56  data bytes, press CTRL_C to break
    Reply from 10.0.23.3: bytes=56 Sequence=1 ttl=254 time=80 ms
    Reply from 10.0.23.3: bytes=56 Sequence=2 ttl=254 time=30 ms
    Reply from 10.0.23.3: bytes=56 Sequence=3 ttl=254 time=30 ms
    Reply from 10.0.23.3: bytes=56 Sequence=4 ttl=254 time=50 ms
    Reply from 10.0.23.3: bytes=56 Sequence=5 ttl=254 time=30 ms

  --- 10.0.23.3 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 30/44/80 ms

  發現AR1與AR3可以相互連通;

4、路由信息三種來源:

以如下拓撲結構爲例,來討論三種路由信息來源:

(1)直連路由(自動添加)

路由優先級與度量值都爲0,並且不可以修改;

(2)靜態路由(需要管理員手動添加)

  查看AR1中的靜態路由:display ip routing-table protocol static

[AR1]display ip routing-table protocol static
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : Static
         Destinations : 1        Routes : 1        Configured Routes : 1

Static routing table status : <Active>
         Destinations : 1        Routes : 1

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

      10.0.23.0/24  Static  60   0          RD   10.0.12.2       GigabitEthernet
0/0/0

Static routing table status : <Inactive>
         Destinations : 0        Routes : 0

  可以發現AR1中,靜態路由是上述添加的,原來是沒有靜態路由的。

  靜態路由比動態路由更加穩定、更加可控、更容易部署,缺點擴展性差、無法反映拓撲的變化。

(3)動態路由(根據路由協議獲取鄰居網絡路由)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章