案例:OSPF 邻居无法建立的常见原因
背景
两台核心交换机之间运行 OSPF,但邻居状态卡在 ExStart 或 Attempt,路由学不到。
常见原因 TOP 5
1. Hello/Dead 时间不一致
! 设备 A
interface GigabitEthernet0/1
ip ospf hello-interval 5
! 设备 B(默认)
interface GigabitEthernet0/1
! 默认 hello=10s, dead=40s
解决:两端时间参数必须一致,或保持默认。
2. Area ID 不匹配
! 设备 A
router ospf 1
network 10.0.0.0 0.0.0.255 area 0
! 设备 B
router ospf 1
network 10.0.0.0 0.0.0.255 area 1 ! 错误!
3. 网络掩码不匹配(点到点链路)
OSPF 在 P2P 链路不检查掩码,但广播型网络会检查!
4. 接口 passive-interface
router ospf 1
passive-interface GigabitEthernet0/1 ! 不发 Hello
5. MTU 不匹配(卡在 ExStart)
两端 MTU 不同会导致数据库描述包过大,邻居卡在 ExStart 阶段。
! 解决:两端一致或调整 MTU 忽略检查
interface GigabitEthernet0/1
ip ospf mtu-ignore
🔍 排查命令速查
show ip ospf neighbor # 查看邻居状态
show ip ospf interface <int> # 查看接口 OSPF 配置
debug ip ospf adj # 实时调试(慎用)
💡 经验
- OSPF 邻居建立要满足 5 个必要条件:区域、掩码、Hello/Dead、认证、网络类型
- 卡在哪个状态就查哪个方面
- ExStart 卡死 优先查 MTU
关注公众号「网英的日常」,更多排错案例持续更新。