步驟:
(1)步驟1:配置路由器R1
R1(config)#router ospf 1
R1(config-router)#router-id
R1(config-router)#network
R1(config-router)#network 192.168.1.0
(2)步驟2:配置路由器R2
R2(config)#router ospf 1
R2(config-router)#router-id
R2(config-router)#network
R2(config-router)#network 192.168.1.0
(3)步驟3:配置路由器R3
R3(config)#router ospf 1
R3(config-router)#router-id
R3(config-router)#network
R3(config-router)#network 192.168.1.0
(4)步驟4:配置路由器R4
R4(config)#router ospf 1
R4(config-router)#router-id
R4(config-router)#network
R4(config-router)#network 192.168.1.0
(2)show ip ospf neighbor:查看ospf鄰居關係
R1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
以上輸出代表在該廣播多路訪問網絡中,R1 是DR,R2 是BDR,R3 和R4 爲DROTHER。
【技術要點】
(1)爲了不路由器之間創建徹底鄰接關係而引發的大量開銷,OSPF 要求在多路訪問的網絡中選舉一個DR,每一個路由器都與之創建鄰接關係。選舉DR 的同時也選舉出一個BDR,在DR 失效的時候,BDR 擔負起DR 的職責,並且全部其它路由器只與DR 和BDR 創建鄰接關係;
(2)DR 和BDR 有它們本身的組播地址224.0.0.6;
(3)DR 和BDR 的選舉是以各個網絡爲基礎的,也就是說DR 和BDR 選舉是一個路由器的接口特性,而不是整個路由器的特性;
(4)DR 選舉的原則:
① 首要因素是時間,最早啓動的路由器被選舉成DR;
② 若是同時啓動,或者從新選舉,則看接口優先級(範圍爲0-255),優先級最高的被選舉成DR,默認狀況下,多路訪問網絡的接口優先級爲1,點到點網絡接口優先級爲0,修改接口優先級的命令是「 ip ospf priority」,若是接口的優先級被設置爲0,那麼該接口將不參與DR 選舉;
③ 若是前二者相同,最後看路由器ID,路由器ID 最高的被選舉成DR;
(5)DR 選舉是非搶佔的,除非人爲地從新選舉。從新選舉DR 的方法有兩種,一是路由器從新啓動,二是執行「clear ip ospf process」命令。
(3)debug ip ospf adj:顯示OSPF 鄰接關係建立或中斷的過程
R2#debug ip ospf adj
OSPF adjacency events debugging is on
R2#clear ip ospf process
Reset ALL OSPF processes? [no]: y
*Mar 1 00:18:23.543: OSPF: Interface Ethernet0/0 going Down
*Mar 1 00:18:23.543: OSPF:
state DOWN
*Mar 1 00:18:23.543: OSPF: Neighbor change Event on interface Ethernet0/0
*Mar 1 00:18:23.543: OSPF: DR/BDR election on Ethernet0/0
*Mar 1 00:18:23.547: OSPF: Elect BDR
*Mar 1 00:18:23.547: OSPF: Elect DR
*Mar 1 00:18:23.547: OSPF: Elect BDR
*Mar 1 00:18:23.547: OSPF: Elect DR
*Mar 1 00:18:23.547: DR:
*Mar 1 00:18:23.551: OSPF: Reset adjacency with
WAY
*Mar 1 00:18:23.551: OSPF:
state DOWN
*Mar 1 00:18:23.551: %OSPF-5-ADJCHG: Process 1, Nbr
FULL to DOWN, Neighbor Down: Interface down or detached
*Mar 1 00:18:23.555: OSPF: Neighbor change Event on interface Ethernet0/0
*Mar 1 00:18:23.555: OSPF: DR/BDR election on Ethernet0/0
*Mar 1 00:18:23.555: OSPF: Elect BDR
*Mar 1 00:18:28.803: OSPF: Rcv LS UPD from
count 100:18:23.555: DR:
*Mar 1 00:18:29.127: OSPF: Rcv LS UPD from
count 100:18:23.559: OSPF:
*Mar 1 00:18:29.179: OSPF: Rcv LS UPD from
count 100:18:23.559: %OSPF-5-ADJCHG: Process 1, Nbr
*Mar 1 00:18:29.571: OSPF: Build router LSA for area 0, router ID
0x80000004:18:23.559: OSPF: Neighbor change Event on interface Ethernet0/0
*Mar 1 00:18:29.611: OSPF: Rcv LS UPD from
count 100:18:23.563: OSPF: Elect BDR
*Mar 1 00:18:31.475: %CDP-4-DUPLEX_MISMATCH: duplex mismatch discovered on Ethe
rnet0/0 (not full duplex), with Router FastEthernet0/2 (full duplex).
*Mar 1 00:18:23.563: OSPF:
state DOWN
*Mar 1 00:18:23.567: %OSPF-5-ADJCHG: Process 1, Nbr
FULL to DOWN, Neighbor Down: Interface down or detached
*Mar 1 00:18:23.567: OSPF: Neighbor change Event on interface Ethernet0/0
*Mar 1 00:18:23.567: OSPF: DR/BDR election on Ethernet0/0
*Mar 1 00:18:23.571: OSPF: Elect BDR
*Mar 1 00:18:23.571: OSPF: Elect DR
*Mar 1 00:18:23.571: DR: none BDR: none
*Mar 1 00:18:23.571: OSPF: Remember old DR
*Mar 1 00:18:23.571: OSPF: Interface Loopback0 going Down
*Mar 1 00:18:23.575: OSPF:
DOWN
*Mar 1 00:18:23.655: OSPF: Interface Ethernet0/0 going Up
*Mar 1 00:18:23.655: OSPF: Interface Loopback0 going Up
*Mar 1 00:18:23.675: OSPF: 2 Way Communication to
2WAY
*Mar 1 00:18:23.679: OSPF: Backup seen Event before WAIT timer on Ethernet0/0
*Mar 1 00:18:23.679: OSPF: DR/BDR election on Ethernet0/0
*Mar 1 00:18:23.679: OSPF: Elect BDR
*Mar 1 00:18:23.679: OSPF: Elect DR
*Mar 1 00:18:23.679: DR:
*Mar 1 00:18:23.683: OSPF: Send DBD to
2 flag 0x7 len 32
*Mar 1 00:18:23.683: OSPF: 2 Way Communication to
2WAY
*Mar 1 00:18:23.687: OSPF: Neighbor change Event on interface Ethernet0/0
*Mar 1 00:18:23.687: OSPF: DR/BDR election on Ethernet0/0
*Mar 1 00:18:23.687: OSPF: Elect BDR
*Mar 1 00:18:23.687: OSPF: Elect DR
*Mar 1 00:18:23.687: DR:
*Mar 1 00:18:23.691: OSPF: Send DBD to
52 flag 0x7 len 32
*Mar 1 00:18:23.691: OSPF: Remember old DR
*Mar 1 00:18:23.691: OSPF: Neighbor change Event on interface Ethernet0/0
*Mar 1 00:18:23.691: OSPF: DR/BDR election on Ethernet0/0
*Mar 1 00:18:23.695: OSPF: Elect BDR
*Mar 1 00:18:23.695: OSPF: Elect DR
*Mar 1 00:18:23.695: DR:
*Mar 1 00:18:23.695: OSPF: 2 Way Communication to
2WAY
*Mar 1 00:18:23.699: OSPF: Neighbor change Event on interface Ethernet0/0
*Mar 1 00:18:23.699: OSPF: DR/BDR election on Ethernet0/0
*Mar 1 00:18:23.699: OSPF: Elect BDR
*Mar 1 00:18:23.699: OSPF: Elect DR
*Mar 1 00:18:23.699: DR:
*Mar 1 00:18:23.703: OSPF: Neighbor change Event on interface Ethernet0/0
*Mar 1 00:18:23.703: OSPF: DR/BDR election on Ethernet0/0
*Mar 1 00:18:23.703: OSPF: Elect BDR
*Mar 1 00:18:23.703: OSPF: Elect DR
*Mar 1 00:18:23.703: DR:
*Mar 1 00:18:23.719: OSPF: Rcv DBD from
以上的輸出代表:
① DR 從新選舉的過程和結果,新的DR 是R1,BDR 是R4;
② 在OSPF 鄰接關係創建的過程當中,接口的狀態的變化包括DOWN、2 Way、EXSTART、
EXCHANGE、Loading 和FULL。