OSPF 邻居关系不能正常建立的原因和解决方法
(1)接口上没有激活 ospf 

 
(2)物理层或者是数据链路层协议 down. 
(3)建立邻居的接口被 passive掉 
(4)OSPF的 hello 组播地址被 ACL Block

(5)在 broadcast链路上的子网掩码不匹配
(6)Hello/dead 间隔不匹配
(7)认证方式或者是认证密码不匹配
使用 debug ip ospf adj 来查看,可以自己使用不同的情况来验证
(8)两台路由器处于不同的 AREA 
(9)Stub/transit/NSSA 区域类型不匹配
这个是常常不小心会被忘记的。
R1#debug ip ospf adj
OSPF adjacency events debugging is on
R1#
OSPF: Rcv hello from 131.108.0.1 area 1 from Ethernet0 131.108.1.2
OSPF: Hello from 131.108.1.2 with mismatched Stub/Transit area option bit
R1#debug ip ospf adj
OSPF adjacency events debugging is on
R1#
OSPF: Rcv hello from 131.108.0.1 area 1 from Ethernet0 131.108.1.2
OSPF: Hello from 131.108.1.2 with mismatched NSSA option bit 
(10)使用 secondary IP来建立 OSPF adjacency  
 
R2#
interface FastEthernet0/0
ip address 131.108.1.2 255.255.255.0 secondary
ip address 131.108.4.2 255.255.255.0
R1#
interface Ethernet0
ip address 131.108.1.1 255.255.255.0
R2#debug ip ospf adj
OSPF adjacency events debugging is on
R2#
OSPF: Rcv pkt from 131.108.1.1, FastEthernet0/0, area 0.0.0.1 : src not on the same network
 
(11)OSPF网络类型不匹配(P-TO-P 和 P-TO-M网络类型在 hello 时间间隔相同的情况下可
以建立 full 关系,
     但是会缺少一条路由可以做一下相关使用验证)
 
(12)NBMA (Frame Relay, X.25, SMDS, and so on)网络类型上没有手动指定 neighbor ip
地址 邻居一直都是 ATTEMPT 状态
 
(13)在 Router 两边的 frame-relay map/dialer map语句声明中缺少了 broadcast参数
 
(14)接口两边的 MTU 不匹配
在 cisco ios 12.0.3中加入了对 mtu 的检测,而低于这个版本的 ios 会忽略 mtu检测,需要查看
router 的 ios version,debug ip ospf adj的结果是发现有大量的 dbd重传,出现loading的原因
就是一边的 router需要对mtu 进行检测,而一边忽略。
R2#debug ip ospf adj
OSPF adjacency events debugging is on
R2#
OSPF: Retransmitting request to 131.108.2.1 on Serial0
OSPF: Database request to 131.108.2.1
OSPF: sent LS REQ packet to 131.108.1.1, length 12
OSPF: Retransmitting request to 131.108.2.1 on Serial0
解决方法是接口命令:mtu 4470  而不是:ip mtu 4470
这时候的状态是 loading 。
R2#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
131.108.2.1 1 LOADING/- 00:00:37 131.108.1.1 Serial0
还有一种 mtu 不匹配的情况是邻居关系是 EXSTART,因为两边的 mtu都需要检测,而 mtu 大
小又不匹配.
R2#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface 131.108.2.1 1 EXSTART/- 00:00:33 131.108.1.1 Serial0
R1#debug ip ospf adj
OSPF: Retransmitting DBD to 131.108.1.2 on Serial0.1
OSPF: Send DBD to 131.108.1.2 on Serial0.1 seq 0x1E55 opt 0x2 flag 0x7 len 32
OSPF: Rcv DBD from 131.108.1.2 on Serial0.1 seq 0x22AB opt 0x2 flag 0x7 len 32 mtu 1500
state EXSTART
OSPF: Nbr 131.108.1.2 has larger interface MTU
 
(15)在 broadcast网络上需要选举 dr,而这时候两边的优先级又都是 0
 
(16)在 Asynchronous Interfaces上的 OSPF 邻居关系
R1#
interface Async1
description ASYNC LINE TO R2
ip address 131.108.1.1 255.255.255.0
encapsulation ppp
async mode dedicated
dialer in-band
dialer map ip 131.108.1.2 name Router2 broadcast
dialer-group 1
ppp authentication chap
R2#
interface Async1
description ASYNC LINE TO R1
ip address 131.108.1.2 255.255.255.0
encapsulation ppp
async mode dedicated
dialer in-band
dialer map ip 131.108.1.1 name Router2 broadcast
dialer-group 1
ppp authentication chap
解决方法是在两个使用 async default routing 或者 asyn dynamic routing 接口命令
 
(15)两个路由器的 Router id相同,ospf的 master和 slave关系不能确定
R2#debug ip ospf adj
OSPF: Retransmitting DBD to 131.108.2.1 on Serial0
OSPF: Send DBD to 131.108.2.1 on Serial0 seq 0x793 opt 0x2 flag 0x7 len 32
OSPF: Rcv DBD from 131.108.2.1 on Serial0 seq 0x25F7 opt 0x2 flag 0x7 len 32 mtu 0
stateEXSTART
OSPF: First DBD and we are not SLAVE
 
(16)因为router接口的物理问题而导致的  ospf packet checksum错误, 接着就重传的问题。 
R2#show log
%OSPF-4-ERRRCV: Received invalid packet: Bad Checksum from 131.108.1.1, Serial0 %OSPF-4-ERRRCV: Received invalid packet: Bad Checksum from 131.108.1.1, Serial0
 
R2#debug ip ospf adj
OSPF adjacency events debugging is on
R2#
OSPF: Retransmitting request to 131.108.2.1 on Serial0
OSPF: Database request to 131.108.2.1
OSPF: sent LS REQ packet to 131.108.1.1, length 12
OSPF: Retransmitting request to 131.108.2.1 on Serial0
针对MTU的OSPF的邻居关系无法建立的问题,其实经过偶实践还有另外一种解决方法是在接口
模式下输入
 
ip ospf mtu-ignore
 
R1(config)#inter s1/1
R1(config-if)#ip ospf mtu-ignore