動態路由之OSPF和RIP協議實現全網互連互通

動態路由之OSPF和RIP協議實現全網互連互通

動態路由是指路由器能夠自動地建立自己的路由表,並且能夠根據實際情況的變化適時地進行調整。

簡述

動態路由是與靜態路由相對的一個概念,指路由器能夠根據路由器之間的交換的特定路由信息自動地建立自己的路由表,並且能夠根據鏈路和節點的變化適時地進行自動調整。當網絡中節點或節點間的鏈路發生故障,或存在其它可用路由時,動態路由可以自行選擇最佳的可用路由並繼續轉發報文。

原理

動態路由機制的運作依賴路由器的兩個基本功能:路由器之間適時的路由信息交換,對路由表的維護:

  1. 路由器之間適時地交換路由信息。
    動態路由之所以能根據網絡的情況自動計算路由、選擇轉發路徑,是由於當網絡發生變化時,路由器之間彼此交換的路由信息會告知對方網絡的這種變化,通過信息擴散使所有路由器都能得知網絡變化。
  2. 路由器根據某種路由算法(不同的動態路由協議算法不同)把收集到的路由信息加工成路由表,供路由器在轉發IP報文時查閱。
    在網絡發生變化時,收集到最新的路由信息後,路由算法重新計算,從而可以得到最新的路由表。

協議

RIP

路由信息協議(RIP) 是內部網關協議IGP中最先得到廣泛使用的協議。RIP是一種分佈式的基於距離向量的路由選擇協議,是因特網的標準協議,其最大優點就是實現簡單,開銷較小。

OSPF

OSPF(Open Shortest Path First開放式最短路徑優先)是一個內部網關協議(Interior Gateway Protocol,簡稱IGP),用於在單一自治系統(autonomous system,AS)內決策路由。

IS-IS

IS-IS(Intermediate System-to-Intermediate System,中間系統到中間系統)路由協議最初是ISO(the International Organization for Standardization,國際標準化組織)爲CLNP(Connection Less Network Protocol,無連接網絡協議)設計的一種動態路由協議。

BGP

邊界網關協議(BGP)是運行於 TCP 上的一種自治系統的路由協議。 BGP 是唯一一個用來處理像因特網大小的網絡的協議,也是唯一能夠妥善處理好不相關路由域間的多路連接的協議。

特點

1、無需管理員手工維護,減輕了管理員的工作負擔。

2、佔用了網絡帶寬。

3、在路由器上運行路由協議,使路由器可以自動根據網絡拓樸結構的變化調整路由條目;

4、網絡規模大、拓撲復雜的網絡

配置實驗

實驗拓撲圖

image

配置過程

R1路由器的配置

R1#conf t
R1(config)#int f0/0
R1(config-if)#ip add 192.168.20.2 255.255.255.0
R1(config-if)#no shut    //f0/0接口配置IP地址並且開啓

R1(config-if)#int f0/1
R1(config-if)#ip add 192.168.30.1 255.255.255.0
R1(config-if)#no shut    //f0/1接口配置IP地址並且開啓

R1(config)#ip route 192.168.10.0 255.255.255.0 192.168.20.1        //配置到192.168.10.0網段的靜態路由

R1(config)#router ospf 1    //開啓ospf協議
R1(config-router)#network 192.168.30.0 255.255.255.0 area 1      //在area 1 宣告192.168.30.0網段
R1(config-router)#redistribute static subnets     //重分發靜態路由
R1(config-router)#redistribute connected subnets    //重分發直連網段

R2路由器的配置

R2#conf t
R2(config)#int f0/0
R2(config-if)#ip add 192.168.10.1 255.255.255.0
R2(config-if)#no shut     //f0/0接口配置IP並且開啓

R2(config)#int f0/1
R2(config-if)#ip add 192.168.20.1 255.255.255.0
R2(config-if)#no shut     //f0/1接口配置IP並且開啓

R2(config)#ip route 0.0.0.0 0.0.0.0 192.168.20.2     //配置默認路由

R3路由器的配置

R3#conf t
R3(config)#int f0/0
R3(config-if)#ip add 192.168.30.2 255.255.255.0
R3(config-if)#no shut     //f0/0接口配置IP並且開啓

R3(config)#int f0/1
R3(config-if)#ip add 192.168.40.1 255.255.255.0
R3(config-if)#no shut     //f0/1接口配置IP並且開啓

R3(config)#int f1/1
R3(config-if)#no switchport    //開啓路由功能
R3(config-if)#ip add 12.0.0.1 255.255.255.0       
R3(config-if)#no shut       //f1/1接口配置IP並且開啓

R3(config)#int f1/0
R3(config-if)#no switchport
R3(config-if)#ip add 192.168.70.1 255.255.255.0      
R3(config-if)#no shut     //f1/0接口配置IP並且開啓

R3(config)#router ospf 1       //開啓ospf協議
R3(config-router)#network 192.168.30.0 255.255.255.0 area 1      //在area 1 宣告192.168.30.0網絡
R3(config-router)#network 192.168.40.0 255.255.255.0 area 0      //在area 0 宣告192.168.40.0網絡
R3(config-router)#network 192.168.70.0 255.255.255.0 area 0      //在area 0 宣告192.168.70.0網絡
R3(config-router)#ex 

R3(config)#ip route 0.0.0.0 0.0.0.0 12.0.0.2     //配置默認路由

R3(config)#router ospf 1
R3(config-router)#default-information originate    //重分發默認路由

R4路由器的配置

R4#conf t
R4(config)#int f0/0
R4(config-if)#ip add 192.168.40.2 255.255.255.0
R4(config-if)#no shut     //f0/0接口配置IP並且開啓

R4(config)#int f0/1
R4(config-if)#ip add 192.168.50.1 255.255.255.0
R4(config-if)#no shut     //f0/1接口配置IP並且開啓

R4(config)#router ospf 1     //開啓ospf協議
R4(config-router)#network 192.168.40.0 255.255.255.0 area 0    //在area 0 宣告192.168.40.0網段

R4(config)#router rip    //開啓rip協議
R4(config-router)#version 2    //選擇版本2
R4(config-router)#network 192.168.50.0   //宣告192.168.50.0網段
R4(config-router)#no auto-summary    //關閉路由彙總
R4(config-router)#ex

R4(config)#router ospf 1  
R4(config-router)#redistribute rip subnets   //在ospf協議中重分發RIP

R4(config)#router rip
R4(config-router)#redistribute ospf 1 metric 3     //在RIP協議中重分發ospf,跳數爲3 (這裏3-5最合適)
R4(config-router)#ex

R5(ISP運營商)的配置

ISP#conf t
ISP(config)#int f0/0
ISP(config-if)#ip add 12.0.0.2 255.255.255.0
ISP(config-if)#no shut     //f0/0配置IP並且開啓
ISP(config-if)#ex

ISP(config)#int f0/1
ISP(config-if)#ip add 13.0.0.1 255.255.255.0
ISP(config-if)#no shut      //f0/1配置IP並且開啓                 
ISP(config-if)#ex

ISP(config)#ip route 0.0.0.0 0.0.0.0 12.0.0.1     //配置默認路由

R6路由器的配置

R6#conf t
R6(config)#int f0/0
R6(config-if)#ip add 192.168.50.2 255.255.255.0
R6(config-if)#no shut      //f0/0接口配置IP並且開啓
R6(config-if)#ex

R6(config)#int f0/1
R6(config-if)#ip add 192.168.60.1 255.255.255.0
R6(config-if)#no shut       //f0/1接口配置IP並且開啓
R6(config-if)#ex 

R6(config)#router rip       //開啓RIP協議
R6(config-router)#version 2     //選擇版本2
R6(config-router)#network 192.168.50.0   //在RIP協議中宣告192.168.50.0網段
R6(config-router)#network 192.168.60.0    //宣告192.168.60.0網段
R6(config-router)#no auto-summary    //關閉路由彙總
R6(config-router)#ex

配置完畢後我們逐個查看路由器的路由表

R1路由器的路由表

image

R2路由器的路由表

image

R3路由器的路由表

image

R4路由器的路由表

image

R5(ISP)路由器的路由表

image

R6路由器的路由表

image

好,接下來我們使用vpcs配置四臺pc機的IP進行全網互通的驗證

image

image

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