動態路由實現OSPF和RIP協議實現全網互連互通
是指路由器能夠自動地建立自己的路由表,並且能夠根據實際情況的變化適時地進行調整。
原理:
動態路由機制的運作依賴路由器的兩個基本功能:路由器之間適時的路由信息交換,對路由表的維護:
路由器之間適時地交換路由信息。
動態路由之所以能根據網絡的情況自動計算路由、選擇轉發路徑,是由於當網絡發生變化時,路由器之間彼此交換的路由信息會告知對方網絡的這種變化,通過信息擴散使所有路由器都能得知網絡變化。
路由器根據某種路由算法(不同的動態路由協議算法不同)把收集到的路由信息加工成路由表,供路由器在轉發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、網絡規模大、拓撲復雜的網絡
配置實驗:
實驗拓撲圖
配置過程:
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路由器的路由表
R2路由器的路由表
R3路由器的路由表
R4路由器的路由表
R5(ISP)路由器的路由表
R6路由器的路由表
接下來我們使用vpcs配置四臺pc機的IP進行全網互通的驗證
動態路由實現OSPF和RIP協議實現全網互連互通