OSPF经典案例分析

  1. 网络拓扑规划

设备:2台华为路由器(R1、R2)

接口:各设备1个物理接口互联,1个Loopback接口

区域:全部配置在OSPF Area 0

IP规划:

  • R1-G0/0/0: 192.168.1.1/30

  • R2-G0/0/0: 192.168.1.2/30

  • R1-Loopback0: 1.1.1.1/32

  • R2-Loopback0: 2.2.2.2/32

  1. OSPF规划

· OSPF进程号:1

· Router-ID:手动指定(建议使用Loopback地址)

· 网络类型:广播(默认)

· 认证:可选配置(本案例不配置)

二、拓扑图

三、完整配置命令

R1 配置

系统视图

sysname R1

配置接口IP地址

interface GigabitEthernet0/0/0

ip address 192.168.1.1 255.255.255.252

undo shutdown

description To_R2_G0/0/0

配置Loopback接口

interface LoopBack0

ip address 1.1.1.1 255.255.255.255

description OSPF_Router-ID

配置OSPF

ospf 1 router-id 1.1.1.1

area 0.0.0.0

network 192.168.1.0 0.0.0.3 # 宣告直连网络

network 1.1.1.1 0.0.0.0 # 宣告Loopback地址

R2 配置

系统视图

sysname R2

配置接口IP地址

interface GigabitEthernet0/0/0

ip address 192.168.1.2 255.255.255.252

undo shutdown

description To_R1_G0/0/0

配置Loopback接口

interface LoopBack0

ip address 2.2.2.2 255.255.255.255

description OSPF_Router-ID

配置OSPF

ospf 1 router-id 2.2.2.2

area 0.0.0.0

network 192.168.1.0 0.0.0.3 # 宣告直连网络

network 2.2.2.2 0.0.0.0 # 宣告Loopback地址

四、验证命令

查看OSPF邻居状态

display ospf peer brief

查看OSPF邻居详细信息

display ospf peer

查看OSPF路由表

display ospf routing

查看OSPF接口信息

display ospf interface

查看全局路由表

display ip routing-table protocol ospf

查看OSPF的LSDB

display ospf lsdb

五、关键注意点

  1. 基础配置注意事项

· Router-ID唯一性:必须确保两台设备的Router-ID不同

· 网络宣告:通配符掩码使用正确(0表示匹配,1表示忽略)

· 区域一致性:直连链路必须在同一区域(本例均为Area 0)

· 接口状态:确保物理接口和协议均为up状态

  1. OSPF邻居建立条件检查表

检查项 要求 常见问题

接口IP地址 在同一网段 子网掩码不匹配

OSPF区域 相同 区域ID配置错误

网络类型 一致 一端为广播,一端为点对点

Hello/Dead间隔 相同 默认Hello=10s, Dead=40s

认证参数 一致(如配置) 认证类型/密码不匹配

MTU值 相同(华为默认检查) MTU不一致导致卡在ExStart

  1. 华为设备特有注意事项

· 进程号本地有效:不同设备的OSPF进程号可以不同

· Router-ID选举:手动配置优先于自动选举

· 默认路由:OSPF默认不生成默认路由,需使用default-route-advertise

· DR/BDR选举:广播网络中会自动选举,优先级高的为DR(默认为1)

  1. 故障排除步骤

1. 检查物理连通性

ping 192.168.1.2

2. 检查接口配置

display ip interface brief

3. 检查OSPF邻居状态

display ospf peer

4. 查看OSPF调试信息(需谨慎)

terminal monitor

terminal debugging

debugging ospf event

故障排除后关闭调试

undo debugging all

  1. 扩展配置建议

1. 修改OSPF优先级(影响DR选举)

interface GigabitEthernet0/0/0

ospf dr-priority 100 # 设置优先级为100

2. 配置OSPF认证(增加安全性)

ospf 1

area 0

authentication-mode simple cipher Huawei@123

3. 修改网络类型(避免DR选举)

interface GigabitEthernet0/0/0

ospf network-type p2p # 改为点对点类型

4. 调整计时器(大型网络优化)

interface GigabitEthernet0/0/0

ospf timer hello 30 # 修改Hello时间为30秒

ospf timer dead 120 # 修改Dead时间为120秒

相关推荐
用户83562907805121 小时前
Python Word 转 PDF 和 PDF 转 Word 指南
后端·python
用户83562907805121 小时前
如何使用 Python 加密和保护 Word 文档
后端·python
Fluxproxy21 小时前
AI数据集采集、批量模型推理报错频发?AI项目网络稳定性优化实战
python·ai·ai编程
Fanta丶1 天前
10.Python class类的定义和魔术方法
python
小玮看世界1 天前
[Python]从“脏”数据到优雅实现:一个IoT滑动窗口最大值问题的测试驱动优化实录
linux·前端·python
MC皮蛋侠客1 天前
SQLAlchemy 系列(十一):从 1.x 到 2.x——渐进迁移与数据访问层治理
数据库·python
魔镜前的帅比1 天前
(开源项目)x-claw (设计)
python·ai·rust·开源
风起洛阳@不良使1 天前
springmvc中Model和ModelAndView
开发语言·python
谢尔登1 天前
分享一些我常用的Skill
java·人工智能·python·actionscript
k4m7v2pz1 天前
macOS 解压 40GB 分卷+中文密码固件镜像的五个深坑与解决方案
python·7-zip·aes加密·踩坑记录·r36s·多卷zip解压