單多區域OSPF實驗
一、OSPF簡介
OSPF是一種內部網關協議,一種開放式最短路徑優先選擇協議,用於單一自治系統內決策路由,是對鏈路狀態路由協議的一種實現。
二、實驗原理
簡單來說就是兩個相鄰的路由器通過發報文的形式稱為鄰居關系,鄰居在相互發送鏈路狀態信息形成鄰接關系,之后各自根據最短路徑算法算出路由,放在OSPF路由表中。整個過程使用了五種包類型和七種狀態。
五種ospf包類型:
Hello包:建立並維護鄰居關系。
DBD(數據庫描述包):發送鏈路狀態頭部信息。
LSR(鏈路狀態請求包):把從DBD中找出需要的鏈路狀態頭部信息傳給鄰居,請求完整信息。
LSU(鏈路狀態更新包):收到LSR后發送鏈路狀態通告(LSA),一個LSU可包含多個LSA。
LSACK(鏈路狀態確認包):收到LSU包后確認,每個LSA需要被分別確認。
七種狀態:
down狀態 init狀態 2way狀態 exstart狀態
exchange狀態 loading狀態 full狀態
三、OSPF特點
1、可適應大規模網絡
2、路由變化收斂速度快
3、無路由環
4、支持變長子網掩碼VLSM
5、支持區域划分
6、支持以組播地址發送協議報
四、實驗配置
1、單區域
主機,交換機配置如圖所示,不再給出,相信各位大佬都能配置出來,三個主機的ospf配置都相同,所以下面只給出各交換機的ospf配置:
# switch0
Switch>ena
Switch#conf
Switch(config)#router ospf 101 #101:ospf id
Switch(config-router)#network 192.168.10.0 0.0.0.255 area 0
Switch(config-router)#network 192.168.20.0 0.0.0.255 area 0
Switch(config-router)#network 10.10.10.0 0.0.0.255 area 0
# switch1
Switch>ena
Switch#conf
Switch(config)#router ospf 102 #101:ospf id
Switch(config-router)#network 192.168.30.0 0.0.0.255 area 0
Switch(config-router)#network 10.10.10.0 0.0.0.255 area 0
Switch(config-router)#network 10.10.30.0 0.0.0.255 area 0
# switch2
Switch>ena
Switch#conf
Switch(config)#router ospf 103 #101:ospf id
Switch(config-router)#network 192.168.40.0 0.0.0.255 area 0
Switch(config-router)#network 192.168.50.0 0.0.0.255 area 0
Switch(config-router)#network 10.10.30.0 0.0.0.255 area 0
2、多區域
主機,交換機配置和單區域相同,下面只給出三個交換機的ospf配置:
··
# switch0
Switch>ena
Switch#conf
Switch(config)#router ospf 101 #101:ospf id
Switch(config-router)#network 192.168.10.0 0.0.0.255 area 1
Switch(config-router)#network 192.168.20.0 0.0.0.255 area 1
Switch(config-router)#network 10.10.10.0 0.0.0.255 area 1
# switch1
Switch>ena
Switch#conf
Switch(config)#router ospf 102 #101:ospf id
Switch(config-router)#network 192.168.30.0 0.0.0.255 area 1
Switch(config-router)#network 10.10.10.0 0.0.0.255 area 1
Switch(config-router)#network 10.10.30.0 0.0.0.255 area 0
# switch2
Switch>ena
Switch#conf
Switch(config)#router ospf 103 #101:ospf id
Switch(config-router)#network 192.168.40.0 0.0.0.255 area 0
Switch(config-router)#network 192.168.50.0 0.0.0.255 area 0
Switch(config-router)#network 10.10.30.0 0.0.0.255 area 0
五、實驗結果
# 單區域結論
未配置ospf之前,不同主機之間不能互通
配置ospf之后,所有主機之間互相ping通
# 多區域結論
配置ospf之后,兩區域之間所有主機相互都能ping通