靜態路由


1. 路由基礎

1.1 路由概述

路由的作用:

  • 指引數據的轉發
  • 三層查詢:目的IP地址

路由查詢:

  • 不用關心網絡地址和廣播地址能不能用
  • 每經過一台三層設備都會進行查詢路由表
  • 數據傳輸:
    • 變化:MAC地址(源和目的),每經過一個三層轉發都會改變
    • 不變:IP地址(源和目的)
  • 命令:
    • 思科:show ip route
    • 華為:display ip routing

路由的組成:

  • 網段:網絡地址 + 掩碼
  • 出口:接口、下一跳的IP地址
  • 更新源:
    • 直連:設備上配置的路由接口

1.2 路由的分類

1)動態路由

  • IGP(內部網關協議):企業內部使用
    • rip
    • ospf
    • isis
    • eigrp
  • EGP(外部網關協議)
    • BGP:邊界網關協議
    • EGP:被淘汰

2)靜態路由

  •  靜態路由是由網絡管理員手動指定的,網絡變化時,它不會跟着變化。

1.3 路由選路原則

1)最長掩碼匹配

  • 前提:有多條路由,且多條路徑都能匹配
  • 掩碼越長越優

2)管理距離(AD值)

  • 管理距離:路由優先級、AD值
  • 前提:掩碼長度一樣
  • AD值越小越優先
    • 192.168.1.0/24  10
    • 192.168.1.0/24  20
  • AD值:(AD值一樣則表示是同一個路由協議)
    • 思科:
      • 直連:0
      • 靜態:1
      • EIGRP:90
      • OSPF:110
      • RIP:120
    • 華為:
      • 直連:0
      • OSPF:10
      • ISIS:15
      • 靜態路由:60
      • RIP:100

3)度量值(開銷,metric,cost)

  • 度量值:開銷、metric、cost
  • 越小越優先
    • 192.168.1.0/24  AD=10  COST=10
    • 192.168.1.0/24  AD=10  COST=5

4)等價路由

  • 等價路由表示的是,以上幾個條件都一樣的路由
  • 數據負載的方式:
    • 包負載:交換機捆綁路線
    • 流負載:等價路由就是采用流負載

2. 靜態路由

2.1 靜態路由的配置

  • 思科:
    • ip route 172.16.23.0  255.255.255.0  172.16.12.2
    • ip route 172.16.23.0  255.255.255.0  172.16.12.2  9 (最后一個數字是設置優先級,AD值)
  • 華為:
    • ip  route-static  172.16.23.0  24  g0/0/0  172.16.12.2
    • ip  route-static  172.16.23.0  24  172.16.12.2
    • ip  route-static  172.16.23.0  24  172.16.12.2  preference  9(preference是表示設置優先級)

2.2 黑洞路由

  • 黑洞路由null0:表示下一跳為null0直接丟包
  • 命令:ip  route-static  192.168.0.0  24  null0

2.3 浮動路由

  • 浮動路由:
    • 在網段一樣的情況下,根據優先級、度量值來加載最優的路由
    • 做備用線路,下一跳的接口down掉才會切換
  • 配置:
    • ip  route-static  192.168.100.0  24  172.16.13.3
    • ip  route-static  192.168.100.0  24  172.16.12.2  preference  61

2.4 常用命令

思科:

  • 查看配置:show  running-config
  • 查看特定配置:show  run | include  ip route
  • 查看接口情況:show  ip interface brief

華為:

  • 查看配置:display  cur
  • 查看特定配置:display  cur | include ip route
  • 查看接口情況:display  ip  interface  brief

3. 靜態路由實驗

3.1 實驗環境

實驗目的及要求:

  1. 配置靜態路由使得R1能ping通R3
  2. 根據優先級來加載最優的路由(做浮動路由
  3. 在R3的回環接口上分別綁定3個IP地址,使得R1能ping通這些IP地址,並做好路由匯總

3.2 配置IP地址

R1:
    configure terminal
    interface fastEthernet 0/0
    ip address 192.168.12.1 255.255.255.0
    no shutdown
    interface fastEthernet 0/1
    ip address 192.168.14.1 255.255.255.0
    no shutdown
    do show ip interface brief
R2:
    configure terminal
    interface fastEthernet 0/0
    ip address 192.168.12.2 255.255.255.0
    no shutdown
    interface fastEthernet 0/1
    ip address 192.168.23.2 255.255.255.0
    no shutdown
    do show ip interface brief
R3:
    configure terminal
    interface fastEthernet 0/1
    ip address 192.168.23.3 255.255.255.0
    no shutdown
    interface fastEthernet 0/0
    ip address 192.168.34.3 255.255.255.0
    no shutdown
    ### 在環回口上配置IP地址 ###
    interface Loopback 0
    ip address 10.1.1.1 255.255.255.0 
    no shutdown
    interface Loopback 1
    ip address 10.1.2.1 255.255.255.0 
    no shutdown
    interface Loopback 2
    ip address 10.1.3.1 255.255.255.0 
    no shutdown
    do show ip interface brief        
R4:
    configure terminal
    interface fastEthernet 0/0
    ip address 192.168.34.4 255.255.255.0
    no shutdown
    interface fastEthernet 0/1
    ip address 192.168.14.4 255.255.255.0
    no shutdown
    do show ip interface brief

3.3 配置路由

R1:
    configure terminal
    ip route 192.168.23.0 255.255.255.0 192.168.12.2 
    ip route 192.168.34.0 255.255.255.0 192.168.14.4
R3:
    configure terminal
    ip route 192.168.12.0 255.255.255.0 192.168.23.2
    ip route 192.168.14.0 255.255.255.0 192.168.34.4

3.4 對環回地址配置路由

1)沒有進行路由匯總

R1:
    configure terminal
    ip route 10.1.1.0 255.255.255.0 192.168.12.2
    ip route 10.1.2.0 255.255.255.0 192.168.12.2
    ip route 10.1.3.0 255.255.255.0 192.168.12.2
    ip route 10.1.1.0 255.255.255.0 192.168.14.4 10
    ip route 10.1.2.0 255.255.255.0 192.168.14.4 10
    ip route 10.1.3.0 255.255.255.0 192.168.14.4 10    
R2:
    configure terminal
    ip route 10.1.1.0 255.255.255.0 192.168.23.3 
    ip route 10.1.2.0 255.255.255.0 192.168.23.3 
    ip route 10.1.3.0 255.255.255.0 192.168.23.3 
R4:
    configure terminal
    ip route 10.1.1.0 255.255.255.0 192.168.34.3 
    ip route 10.1.2.0 255.255.255.0 192.168.34.3 
    ip route 10.1.3.0 255.255.255.0 192.168.34.3 

2)對環回地址的路由進行匯總

  • 對10.1.1.0和10.1.2.0和10.1.3.0進行路由匯總,掩碼為22位,對應掩碼為255.255.252.0
R1:
    configure terminal
    ip route 10.1.0.0 255.255.252.0 192.168.12.2 
    ip route 10.1.0.0 255.255.252.0 192.168.14.4 10
    ip route 10.1.0.0 255.255.255.0 null 0
R2:
    configure terminal
    ip route 10.1.0.0 255.255.252.0 192.168.23.3 
R4:
    configure terminal
    ip route 10.1.0.0 255.255.252.0 192.168.34.3

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM