需求:R2 ABR路由器向R3路由器发放默认路由
配置:
R2:
router ospf 1
router-id 2.2.2.2
log-adjacency-changes
network 2.2.2.2 0.0.0.0 area 0
network 12.1.1.2 0.0.0.0 area 0
network 23.1.1.1 0.0.0.0 area 23
default-information originate always
加上always关键字后就不需要手工书写默认路由。
验证配置:
R1:
Gateway of last resort is 12.1.1.2 to network 0.0.0.0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] via 12.1.1.2, 00:01:09, Serial1/0
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/129] via 12.1.1.2, 00:01:09, Serial1/0
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.1.1.0 [110/128] via 12.1.1.2, 00:01:09, Serial1/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial1/0
O*E2 0.0.0.0/0 [110/1] via 12.1.1.2, 00:01:09, Serial1/0
R2:
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/65] via 12.1.1.1, 00:10:54, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/65] via 23.1.1.2, 00:10:54, Serial1/1
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial1/0
R3:
Gateway of last resort is 23.1.1.1 to network 0.0.0.0
1.0.0.0/32 is subnetted, 1 subnets
O IA 1.1.1.1 [110/129] via 23.1.1.1, 00:00:12, Serial1/0
2.0.0.0/32 is subnetted, 1 subnets
O IA 2.2.2.2 [110/65] via 23.1.1.1, 00:00:12, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, Serial1/0
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.1.1.0 [110/128] via 23.1.1.1, 00:00:12, Serial1/0
O*E2 0.0.0.0/0 [110/1] via 23.1.1.1, 00:00:12, Serial1/0
总结与思考:默认情况下OSPF不会生成默认路由,并将其注入到OSPF路由
选择域中,需要生成默认路由,必须用命令default-information originate [always]
always 不管路由器的路由选择表中是否有默认路由,总是通告默认路由。
其中默认路由以5类外部LSA的方式出现在OSPF数据库中。