一 、OSPF网络注入默认路由
![1d47cd9981df0c9262fbd79ea1ae998a.png](https://i-blog.csdnimg.cn/blog_migrate/274c17c9860225eb7903bafbc9ed0c0e.jpeg)
二、 实战步骤
1、本实验用 R1 的环回接口 1 来模拟 Internet。
(1)步骤 1:配置路由器 R1
R1(config)# interface loopback 1
R1(config-if)# ip address 5.5.5.5 255.255.255.0
R1(config)# ip route 0.0.0.0 0.0.0.0 loopback 1
R1(config-router)# router-id 1.1.1.1
R1(config-router)# network 1.1.1.0 0.0.0.255 area 0
R1(config-router)# network 192.168.12.0 0.0.0.255 area 0
R1(config-router)# default-information originate
【技术要点 】
“ default-information originate”命令后面可以加可选的“always”参数,如果不
使用该参数,路由器上必须存在一条默认路由,否则该命令不产生任何效果。如果使用该参
数,无论路由器上是否存在默认路由,路由器都会向 OSPF 区域内注入一条默认路由。
(2)步骤 2:路由器 R2、R3 和 R4 的配置同 1 6.2 实验 1 的配置完全相同。
2.实验调试
(1) show ip route
R4# show ip route ospf
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is 192.168.34.3 to network 0.0.0.0
O 192.168.12.0/24 [110/2343] via 192.168.34.3, 00:01:26, Serial0/0/0
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/2344] via 192.168.34.3, 00:01:26, Serial0/0/0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/1563] via 192.168.34.3, 00:01:26, Serial0/0/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/782] via 192.168.34.3, 00:01:26, Serial0/0/0
O 192.168.23.0/24 [110/1562] via 192.168.34.3, 00:01:27, Serial0/0/0
O*E2 0.0.0.0/0 [110/1] via 192.168.34.3, 00:01:27, Serial0/0/0
R3# show ip route ospf
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is 192.168.23.2 to network 0.0.0.0
O 192.168.12.0/24 [110/1562] via 192.168.23.2, 00:05:28, Serial0/0/1
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/1563] via 192.168.23.2, 00:05:28, Serial0/0/1
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/782] via 192.168.23.2, 00:05:28, Serial0/0/1
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/782] via 192.168.34.4, 00:05:28, Serial0/0/0
O*E2 0.0.0.0/0 [110/1] via 192.168.23.2, 00:05:30, Serial0/0/1
从上面R3和R4的路由表的输出,可以看到通过命令“ default-information originate”
确实可以向 OSPF 区域注入一条默认路由。
(2)show ip ospf database
R4# show ip ospf database
OSPF Router with ID (4.4.4.4) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 746 0x80000010 0x000BD7 3
2.2.2.2 2.2.2.2 188 0x80000016 0x00CFB8 5
3.3.3.3 3.3.3.3 163 0x80000007 0x00282D 5
4.4.4.4 4.4.4.4 248 0x80000007 0x009402 3
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
0.0.0.0 1.1.1.1 863 0x80000001 0x001D91 1
三、OSPF 命令汇总
命令 作用
show ip route 查看路由表
show ip ospf neighbor 查看 OSPF 邻居的基本信息
show ip ospf database 查看 OSPF 拓扑结构数据库
show ip ospf interface 查看 OSPF 路由器接口的信息
show ip ospf 查看 OSPF 进程及其细节
debug ip ospf adj 显示 OSPF 邻接关系创建或中断的过程
debug ip ospf events 显示 OSPF 发生的事件
debug ip ospf packet 显示路由器收到的所有的 OSPF 数据包
router ospf 启动 OSPF 路由进程
router-id 配置路由器 ID
network 通告网络及网络所在的区域
ip ospf network 配置接口网络类型
ip ospf cost 配置接口 cost 值
ip ospf hello-interval 配置 hello 间隔
ip ospf dead-interval 配置 OSPF 邻居的死亡时间
ip ospf priority 配置接口优先级
auto-cost reference-bandwidth 配置参考带宽
clear ip ospf process 清除 OSPF 进程
area area-id authentication 启动区域简单口令认证
ip ospf authentication-key cisco 配置认证密码
area area-id authentication message-digest 启动区域 MD5 认证
ip ospf message-digest-key key-id md5 key 配置 key ID 及密匙
ip ospf authentication 启用链路简单口令认证
ip ospf authentication message-digest 启用链路 MD5 认证
default-information originate 向 OSPF 区域注入默认路由
以下是华为数通路由交换方向相关技术分享,欢迎对华为网络技术感兴趣的小伙伴们订阅。
华为新版HCIA数通路由交换
华为新版HCIP数通路由交换
华为新版HCIE数通路由交换