OSPF協議:
一、鏈路狀態型的路由協議
特色:全部路由器上對全網的拓撲都瞭解,即每臺路由器收到的信息不僅是鄰居,經過不一樣(一、二、三、四、五、7)類型的LSA(鏈路狀態通告)去感知全網的網絡
二、OSPF的算法是SPF的算法,樹型結構算法無環路
三、分層區域(骨幹區域area 0和非骨幹區域area 1等)。分層原則:全部的非骨幹區域必須鏈接在骨幹區域上。Ospf的區域是基於接口劃分的。
#router ospf 100==將OSPF定義爲IP路由協議,100位進程號,本地有效
#router-id 2.2.2.2(2.2.2.2每一個網絡裏都是惟一的,感知網絡就是經過router ID來標示每一個路由器.算法
按拓撲圖運行OSPF、 要求全網能通PC1能通PC二、 R1上看到去R4的兩條等價負載均衡。
R1 traceroute R4 R4-R3-R1
R4>enable
configure terminal
interface fa 0/0
no shutdown
ip address 44.1.1.1 255.0.0.0
interface se 3/0
no shutdown
ip address 24.1.1.4 255.0.0.0
interface fa 1/0
no shutdown
ip address 34.1.1.4 255.0.0.0
router ospf 100 將ospf定義爲IP路由協議,進程號爲100 (進程號必須你們一致)
router-id 4.4.4.4 感知網絡就是經過router ID來標示每一個路由器,同個網絡必須都是惟一的
network 44.1.1.0 0.0.0.255 area 0 定義44.1.1.0網段IP 爲骨幹區域area 0
network 24.1.1.0 0.0.0.255 area 0
network 34.1.1.0 0.0.0.255 area 0網絡
R3>enable
configure terminal
interface fa 1/0
no shutdown
ip address 34.1.1.3 255.0.0.0
interface fa 0/0
no shutdown
ip address 192.168.10.3 255.255.255.0
router ospf 100
router-id 3.3.3.3
network 34.1.1.0 0.0.0.255 area 0定義34.1.1.0網段IP 爲骨幹區域area 0
network 192.168.10.0 0.255.255.255 area 1定義192.168.10.0網段IP 爲非骨幹區域area 1
R2配置同上。IP爲:192.168.10.2 24.1.1.2負載均衡
R1>
eanble
configure terminal
interface fa 0/0
no shutdown
ip address 192.168.10.1 255.255.255.0
interface fa 1/0
no shutdown
ip address 11.1.1.1 255.0.0.0
router ospf 100
router-id 1.1.1.1
network 192.168.10.0 0.255.255.255
network 11.1.1.0 0.0.0.255
show ip route
驗證是在端口上生效,必須路由器與路由器鏈接的端口配置密碼同樣。不然就不能訪問。
明文驗證:
#int s1/0
#ip ospf authenticarion-key xxwj 設置驗證密碼啓祕鑰,必須保持一致
#exit
#router ospf 1
#area 1 authentication 開啓驗證
密文驗證:
#int s1/0
#ip ospf message-digest-key 1 md5 ccie
#area 0 authentication messate-digestide
備註:實際中會發現環回口沒法與網絡正常鏈接,是由於子網掩碼不同,OSPF 路由器將環回口的網絡類型認爲是一種特殊的類型, LOOPBACK 類型。所以無論環回口前綴長度爲多少,都一致認爲其長度爲 32。
所以,只須要更改環回口的網絡類型便可。一般更改成點到點網絡類型便可。這樣環回口的子網又變回24了。
R1(config)#int lo0
R1(config-if)#ip ospf network point-to-point3d