ospf邻居邻接关系
原理概述
1.ospf网络中,路由发送的任何链路信息必须建在ospf邻居邻接关系之上
2.hello报文:
1)Router-ID
2)Area-ID
3)认证信息
4)网络掩码
5)Hello时间间隔
2.ospf路由器建立邻居关系建立完成之后,下一步才是建立邻接关系;
3.并不是所有ospf邻居之间都可以建立邻接关系,这取决于ospf邻居之间的网络类型;点到点网络可之间建立邻接关系;在广播型网络上,会选举DR和BDR,DR和BDR会与所有其他路由器建立邻接关系,其他路由器都只与DR和BDR建立邻接关系。
[R1]ospf router-id 10.0.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 10.0.1.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]network 10.0.123.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]q
[R1-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]network 10.0.14.0 0.0.0.255
[R1-ospf-1-area-0.0.0.1]q
[R1-ospf-1]area 2
[R1-ospf-1-area-0.0.0.2]network 10.0.15.0 0.0.0.255
[R1-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 10.0.1.1
area 0.0.0.0
network 10.0.1.1 0.0.0.0
network 10.0.123.0 0.0.0.255
area 0.0.0.1
network 10.0.14.0 0.0.0.255
area 0.0.0.2
network 10.0.15.0 0.0.0.255
#
return
[R2]ospf router-id 10.0.2.2
[R2-ospf-1]area 0
[R2-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 10.0.2.2
area 0.0.0.0
network 10.0.2.2 0.0.0.0
network 10.0.123.0 0.0.0.255
#
return
[R3]ospf router-id 10.0.3.3
[R3-ospf-1]area 0
[R3-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 10.0.3.3
area 0.0.0.0
network 10.0.3.3 0.0.0.0
network 10.0.123.0 0.0.0.255
#
return
[R4]ospf router-id 10.0.4.4
[R4-ospf-1]area 1
[R4-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 10.0.4.4
area 0.0.0.1
network 10.0.4.4 0.0.0.0
network 10.0.14.0 0.0.0.255
#
return
[R5]ospf router-id 10.0.5.5
[R5-ospf-1]area 2
[R5-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 10.0.5.5
area 0.0.0.2
network 10.0.5.5 0.0.0.0
network 10.0.15.0 0.0.0.255
#
return
dis ospf peer brief
OSPF Process 1 with Router ID 10.0.1.1
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 10.0.2.2 Full
0.0.0.0 GigabitEthernet0/0/0 10.0.3.3 Full
0.0.0.1 Serial1/0/0 10.0.4.4 Full
0.0.0.2 Serial1/0/1 10.0.5.5 Full
----------------------------------------------------------------------------
Full表示邻居邻接关系建立成功
dis ospf peer
OSPF Process 1 with Router ID 10.0.1.1
Neighbors
Area 0.0.0.0 interface 10.0.123.1(GigabitEthernet0/0/0)'s neighbors
Router ID: 10.0.2.2 Address: 10.0.123.2
State: Full Mode:Nbr is Master Priority: 1
DR: 10.0.123.3 BDR: 10.0.123.1 MTU: 0
Dead timer due in 37 sec
Retrans timer interval: 5
Neighbor is up for 00:02:56
Authentication Sequence: [ 0 ]
Router ID: 10.0.3.3 Address: 10.0.123.3
State: Full Mode:Nbr is Master Priority: 1
DR: 10.0.123.3 BDR: 10.0.123.1 MTU: 0
Dead timer due in 33 sec
Retrans timer interval: 5
Neighbor is up for 00:03:28
Authentication Sequence: [ 0 ]
Neighbors
Area 0.0.0.1 interface 10.0.14.1(Serial1/0/0)'s neighbors
Router ID: 10.0.4.4 Address: 10.0.14.4
State: Full Mode:Nbr is Master Priority: 1
DR: None BDR: None MTU: 0
Dead timer due in 36 sec
Retrans timer interval: 5
Neighbor is up for 00:02:51
Authentication Sequence: [ 0 ]
Neighbors
Area 0.0.0.2 interface 10.0.15.1(Serial1/0/1)'s neighbors
Router ID: 10.0.5.5 Address: 10.0.15.5
State: Full Mode:Nbr is Master Priority: 1
DR: None BDR: None MTU: 0
Dead timer due in 40 sec
Retrans timer interval: 5
Neighbor is up for 00:02:57
Authentication Sequence: [ 0 ]
可以看到,R1,R2,R3的广播网络完成了DR和BDR的选举,R3为DR,R2为BDR;R1和R4,R1和R5没有选举DR和BDR是因为他们是点到点网络
通过命令
debugging ospf packaget
reset ospf process
可以看到过程
(现在R3 为DR,R1为BDR ;将R1的G0/0/0和R2 的G0/0/0优先级改为0 进行观察)
[R1-GigabitEthernet0/0/0]ospf dr-priority 0
[R2-GigabitEthernet0/0/0]ospf dr-priority 0
R3与R1和R2建立了邻接
R1与DRother路由R2建立了邻居关系
可以看出R1与R3 为邻接full状态,与R2 为邻居状态2-way
[R1]int s1/0/0
[R1-Serial1/0/0]undo shutdown
[R1-Serial1/0/0]int s1/0/1
[R1-Serial1/0/1]undo shutdown
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]shutdown
可以看到R1与R4和R5建立了邻接关系
dis ospf peer brief
OSPF Process 1 with Router ID 10.0.1.1
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.1 Serial1/0/0 10.0.4.4 Full
0.0.0.2 Serial1/0/1 10.0.5.5 Full
----------------------------------------------------------------------------
重启OSPF进行观察状态
Down->init->Exstart->Exchange->Loading->full
得出结论:点到点网络里面,能够建立OSPF邻居关系的路由器一定会继续建立邻接关系
在R1 S1/0/0接口抓包
重启OSPF进程
debugging ospf packet
reset ospf process