OSPF路由汇总
在不使用路由汇总的情况下,每个链路的LSA会发送到OSPF骨干一级其他区域中,这就造成了不必要的网络流量和路由开销。但假如使用路由汇总,只有汇总的路由会传播到骨干区域,避免了大量LSA占用带宽,CPU以及内存资源。即便链路出现了故障,这种变化也不会传播到骨干网络中,使得骨干网络更加稳定。
OSPF有两种汇总方式:
域间汇总:
域间汇总在ABR上进行,命令为在ospf进程下,area 1 range 192.168.20.0 25.255.252.0
域间汇总演示
以下面拓扑图为例
对R1进行配置:
R1>en
R1#conf t
R1(config)#int lo 0
R1(config-if)#ip add 1.1.1.1 255.255.255.255
R1(config-if)#no sh
R1(config-if)#int f0/0
R1(config-if)#ip add 12.1.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#exi
R1(config)#router os 100
R1(config-router)#router-id 1.1.1.1
R1(config-router)#net 1.1.1.1 0.0.0.0 a 0
R1(config-router)#net 12.1.1.0 0.0.0.255 a 0
R1(config-router)#exi
对R2进行配置:
R2>en
R2#conf t
R2(config)#int lo 0
R2(config-if)#ip add 2.2.2.2 255.255.255.255
R2(config-if)#no sh
R2(config-if)#int f0/0
R2(config-if)#ip add 12.1.1.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#exi
R2(config)#int f0/1
R2(config-if)#ip add 23.1.1.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#exi
R2(config)#int f1/0
R2(config-if)#ip add 24.1.1.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#exi
R2(config)#router os 100
R2(config-router)#router-id 2.2.2.2
R2(config-router)#net 2.2.2.2 0.0.0.0 a 0
R2(config-router)#net 12.1.1.0 0.0.0.255 a 0
R2(config-router)#net 23.1.1.0 0.0.0.255 a 1
R2(config-router)#net 24.1.1.0 0.0.0.255 a 2
R2(config-router)#exi
对R3进行配置:
R3>en
R3#conf t
R3(config)#int lo 0
R3(config-if)#ip add 3.3.3.3 255.255.255.255
R3(config-if)#no sh
R3(config-if)#int lo 1
R3(config-if)#ip add 192.168.20.1 255.255.255.0
R3(config-if)#no sh
R3(config-if)#exi
R3(config)#int lo 2
R3(config-if)#ip add 192.168.21.1 255.255.255.0
R3(config-if)#no sh
R3(config-if)#int lo 3
R3(config-if)#ip add 192.168.22.1 255.255.255.0
R3(config-if)#no sh
R3(config-if)#int lo 4
R3(config-if)#ip add 192.168.23.1 255.255.255.0
R3(config-if)#no sh
R3(config-if)#exi
R3(config)#int f0/1
R3(config-if)#ip add 23.1.1.3 255.255.255.0
R3(config-if)#no sh
R3(config-if)#exi
R3(config)#router os 100
R3(config-router)#router-id 3.3.3.3
R3(config-router)#net 3.3.3.3 0.0.0.0 a 1
R3(config-router)#net 192.168.20.1 0.0.0.255 a 1
R3(config-router)#net 192.168.21.1 0.0.0.255 a 1
R3(config-router)#net 192.168.22.1 0.0.0.255 a 1
R3(config-router)#net 192.168.23.1 0.0.0.255 a 1
R3(config-router)#net 23.1.1.0 0.0.0.255 a 1
R3(config-router)#exi
对R4进行配置:
R4>en
R4#conf t
R4(config)#int lo 0
R4(config-if)#ip add 4.4.4.4 255.255.255.255
R4(config-if)#no sh
R4(config-if)#int lo 1
R4(config-if)#ip add 192.168.32.1 255.255.255.0
R4(config-if)#no sh
R4(config-if)#int lo 2
R4(config-if)#ip add 192.168.33.1 255.255.255.0
R4(config-if)#no sh
R4(config-if)#int lo 3
R4(config-if)#ip add 192.168.34.1 255.255.255.0
R4(config-if)#no sh
R4(config-if)#int lo 4
R4(config-if)#ip add 192.168.34.1 255.255.255.0
R4(config-if)#no sh
R4(config-if)#int lo 5
R4(config-if)#ip add 192.168.36.1 255.255.255.0
R4(config-if)#no sh
R4(config-if)#int lo 6
R4(config-if)#ip add 192.168.36.1 255.255.255.0
R4(config-if)#no sh
R4(config-if)#int lo 7
R4(config-if)#ip add 192.168.38.1 255.255.255.0
R4(config-if)#no sh
R4(config-if)#int lo 8
R4(config-if)#ip add 192.168.38.1 255.255.255.0
R4(config-if)#no sh
R4(config-if)#int f0/1
R4(config-if)#ip add 24.1.1.4 255.255.255.0
R4(config-if)#no sh
R4(config-if)#exi
R4(config)#router os 100
R4(config-router)#router-id 4.4.4.4
R4(config-router)#net 4.4.4.4 0.0.0.0 a 2
R4(config-router)#net 192.168.32.0 0.0.0.255 a 2
R4(config-router)#net 192.168.33.0 0.0.0.255 a 2
R4(config-router)#net 192.168.34.0 0.0.0.255 a 2
R4(config-router)#net 192.168.35.0 0.0.0.255 a 2
R4(config-router)#net 192.168.36.0 0.0.0.255 a 2
R4(config-router)#net 192.168.37.0 0.0.0.255 a 2
R4(config-router)#net 192.168.38.0 0.0.0.255 a 2
R4(config-router)#net 192.168.39.0 0.0.0.255 a 2
R4(config-router)#net 24.1.1.0 0.0.0.255 a 2
R4(config-router)#exi
配置成功后我们在R1上看一下路由表:
R1#show ip route
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 not set
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/11] via 12.1.1.2, 00:15:49, FastEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/21] via 12.1.1.2, 00:13:26, FastEthernet0/0
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/12] via 12.1.1.2, 00:11:49, FastEthernet0/0
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.1.1.0 [110/20] via 12.1.1.2, 00:15:48, FastEthernet0/0
192.168.38.0/32 is subnetted, 1 subnets
O IA 192.168.38.1 [110/12] via 12.1.1.2, 00:11:51, FastEthernet0/0
192.168.21.0/32 is subnetted, 1 subnets
O IA 192.168.21.1 [110/21] via 12.1.1.2, 00:13:29, FastEthernet0/0
24.0.0.0/24 is subnetted, 1 subnets
O IA 24.1.1.0 [110/11] via 12.1.1.2, 00:15:42, FastEthernet0/0
192.168.39.0/32 is subnetted, 1 subnets
O IA 192.168.39.1 [110/12] via 12.1.1.2, 00:11:53, FastEthernet0/0
192.168.20.0/32 is subnetted, 1 subnets
O IA 192.168.20.1 [110/21] via 12.1.1.2, 00:13:30, FastEthernet0/0
192.168.23.0/32 is subnetted, 1 subnets
O IA 192.168.23.1 [110/21] via 12.1.1.2, 00:13:30, FastEthernet0/0
192.168.36.0/32 is subnetted, 1 subnets
O IA 192.168.36.1 [110/12] via 12.1.1.2, 00:11:55, FastEthernet0/0
192.168.22.0/32 is subnetted, 1 subnets
O IA 192.168.22.1 [110/21] via 12.1.1.2, 00:13:33, FastEthernet0/0
192.168.37.0/32 is subnetted, 1 subnets
O IA 192.168.37.1 [110/12] via 12.1.1.2, 00:11:56, FastEthernet0/0
192.168.34.0/32 is subnetted, 1 subnets
O IA 192.168.34.1 [110/12] via 12.1.1.2, 00:11:57, FastEthernet0/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
192.168.35.0/32 is subnetted, 1 subnets
O IA 192.168.35.1 [110/12] via 12.1.1.2, 00:11:58, FastEthernet0/0
192.168.32.0/32 is subnetted, 1 subnets
O IA 192.168.32.1 [110/12] via 12.1.1.2, 00:11:59, FastEthernet0/0
192.168.33.0/32 is subnetted, 1 subnets
O IA 192.168.33.1 [110/12] via 12.1.1.2, 00:12:00, FastEthernet0/0
我们可以看见,由于域间路由的传播,R1上多达进20条路由,有R3宣告的4个,R4宣告的8个192.68网段的路由如果不进行汇总,会泛洪到全网,所以我们应该在Area 1和Area 2的ABR上也就是R2上进行汇总操作,具体操作如下:R2(config)#router os 100
R2(config-router)#area 1 range 192.168.20.0 255.255.252.0
R2(config-router)#area 2 range 192.168.32.0 255.255.248.0
R2(config-router)#exi
接下来我们去R1查看一下路由表:
R1#show ip route
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 not set
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/11] via 12.1.1.2, 00:20:48, FastEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/21] via 12.1.1.2, 00:18:26, FastEthernet0/0
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/12] via 12.1.1.2, 00:16:49, FastEthernet0/0
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.1.1.0 [110/20] via 12.1.1.2, 00:20:48, FastEthernet0/0
24.0.0.0/24 is subnetted, 1 subnets
O IA 24.1.1.0 [110/11] via 12.1.1.2, 00:20:40, FastEthernet0/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
O IA 192.168.20.0/22 [110/21] via 12.1.1.2, 00:00:39, FastEthernet0/0
O IA 192.168.32.0/21 [110/12] via 12.1.1.2, 00:00:18, FastEthernet0/0
可以看见,Area 1和Area 2上的192.168网段已经完成了汇总。这样会节省很多资源,拓扑发生变化也不会影响Area 0的路由表。
域外汇总
域外汇总需在ASBR上进行,命令为summary-address 192.168.20.0 25.255.252.0
域外汇总演示
我们拓扑图不变,但将Area 2变为EIGRP
在R2上面更改配置:
R2(config)#router os 100
R2(config-router)#no net 24.1.1.0 0.0.0.255 a 2
R2(config-router)#exi
R2(config)#router ei 90
R2(config-router)#no au
R2(config-router)#net 24.1.1.0 0.0.0.255
R2(config-router)#exi
在R4上更改:
R4(config)#no router os 100
R4(config)#router ei 90
R4(config-router)#no au
R4(config-router)#net 24.1.1.0 0.0.0.255
R4(config-router)#net 4.4.4.4 0.0.0.0
R4(config-router)#net 192.168.32.0 0.0.0.255
R4(config-router)#net 192.168.33.0 0.0.0.255
R4(config-router)#net 192.168.34.0 0.0.0.255
R4(config-router)#net 192.168.35.0 0.0.0.255
R4(config-router)#net 192.168.36.0 0.0.0.255
R4(config-router)#net 192.168.37.0 0.0.0.255
R4(config-router)#net 192.168.38.0 0.0.0.255
R4(config-router)#net 192.168.39.0 0.0.0.255
R4(config-router)#exi
之后我们在R2上进行双向重分发
R2(config)#router os 100
R2(config-router)#redistribute eigrp 90 subnets
R2(config-router)#exi
R2(config)#router ei 90
R2(config-router)#redistribute ospf 100 metric 1000 1 255 1 1500
R2(config-router)#exi
之后再R1查看路由表:
R1#show ip route
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 not set
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/11] via 12.1.1.2, 00:01:31, FastEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/21] via 12.1.1.2, 00:01:31, FastEthernet0/0
4.0.0.0/32 is subnetted, 1 subnets
O E2 4.4.4.4 [110/20] via 12.1.1.2, 00:01:31, FastEthernet0/0
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.1.1.0 [110/20] via 12.1.1.2, 00:01:31, FastEthernet0/0
O E2 192.168.38.0/24 [110/20] via 12.1.1.2, 00:01:32, FastEthernet0/0
24.0.0.0/24 is subnetted, 1 subnets
O E2 24.1.1.0 [110/20] via 12.1.1.2, 00:01:32, FastEthernet0/0
O E2 192.168.39.0/24 [110/20] via 12.1.1.2, 00:01:33, FastEthernet0/0
O E2 192.168.36.0/24 [110/20] via 12.1.1.2, 00:01:34, FastEthernet0/0
O E2 192.168.37.0/24 [110/20] via 12.1.1.2, 00:01:34, FastEthernet0/0
O E2 192.168.34.0/24 [110/20] via 12.1.1.2, 00:01:34, FastEthernet0/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
O E2 192.168.35.0/24 [110/20] via 12.1.1.2, 00:01:35, FastEthernet0/0
O E2 192.168.32.0/24 [110/20] via 12.1.1.2, 00:01:35, FastEthernet0/0
O E2 192.168.33.0/24 [110/20] via 12.1.1.2, 00:01:35, FastEthernet0/0
O IA 192.168.20.0/22 [110/21] via 12.1.1.2, 00:01:35, FastEthernet0/0
可以看见O E2标记的为外部的EIGRP路由,并没有汇总,下面我们在R2上进行域外路由的汇总:
R2(config)#router os 100
R2(config-router)#summary-address 192.168.32.0 255.255.248.0
R2(config-router)#exi
然后我们在R1上查看路由表:
R1#show ip route
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 not set
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/11] via 12.1.1.2, 00:04:44, FastEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/21] via 12.1.1.2, 00:04:44, FastEthernet0/0
4.0.0.0/32 is subnetted, 1 subnets
O E2 4.4.4.4 [110/20] via 12.1.1.2, 00:04:44, FastEthernet0/0
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.1.1.0 [110/20] via 12.1.1.2, 00:04:44, FastEthernet0/0
24.0.0.0/24 is subnetted, 1 subnets
O E2 24.1.1.0 [110/20] via 12.1.1.2, 00:04:46, FastEthernet0/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
O IA 192.168.20.0/22 [110/21] via 12.1.1.2, 00:04:47, FastEthernet0/0
O E2 192.168.32.0/21 [110/20] via 12.1.1.2, 00:00:08, FastEthernet0/0
ok!已经完成了汇总!
下放默认路由的方法
假如我们有一条通往Internet的默认路由,但我们如何将它下放到ospf域内的所有路由器呢,以免我们一台一台的配置,接下来我们还是按照上一个拓扑图来演示一下:
我们假定R2去往R4的就是默认路由,那么我们先在R2上面进行配置:
R2(config)#ip route 0.0.0.0 0.0.0.0 f1/0
R2(config)#do show ip route
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 0.0.0.0 to network 0.0.0.0
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/11] via 12.1.1.1, 00:08:40, FastEthernet0/0
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/11] via 23.1.1.3, 00:08:40, FastEthernet0/1
4.0.0.0/32 is subnetted, 1 subnets
D 4.4.4.4 [90/156160] via 24.1.1.4, 00:14:42, FastEthernet1/0
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, FastEthernet0/1
D 192.168.38.0/24 [90/156160] via 24.1.1.4, 00:14:09, FastEthernet1/0
192.168.21.0/32 is subnetted, 1 subnets
O 192.168.21.1 [110/11] via 23.1.1.3, 00:08:41, FastEthernet0/1
24.0.0.0/24 is subnetted, 1 subnets
C 24.1.1.0 is directly connected, FastEthernet1/0
D 192.168.39.0/24 [90/156160] via 24.1.1.4, 00:14:05, FastEthernet1/0
192.168.20.0/32 is subnetted, 1 subnets
O 192.168.20.1 [110/11] via 23.1.1.3, 00:08:44, FastEthernet0/1
192.168.23.0/32 is subnetted, 1 subnets
O 192.168.23.1 [110/11] via 23.1.1.3, 00:08:44, FastEthernet0/1
D 192.168.36.0/24 [90/156160] via 24.1.1.4, 00:14:20, FastEthernet1/0
192.168.22.0/32 is subnetted, 1 subnets
O 192.168.22.1 [110/11] via 23.1.1.3, 00:08:45, FastEthernet0/1
D 192.168.37.0/24 [90/156160] via 24.1.1.4, 00:14:17, FastEthernet1/0
D 192.168.34.0/24 [90/156160] via 24.1.1.4, 00:14:28, FastEthernet1/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
D 192.168.35.0/24 [90/156160] via 24.1.1.4, 00:14:26, FastEthernet1/0
D 192.168.32.0/24 [90/156160] via 24.1.1.4, 00:14:36, FastEthernet1/0
D 192.168.33.0/24 [90/156160] via 24.1.1.4, 00:14:33, FastEthernet1/0
S* 0.0.0.0/0 is directly connected, FastEthernet1/0
O 192.168.20.0/22 is a summary, 00:08:47, Null0
O 192.168.32.0/21 is a summary, 00:04:08, Null0
我们看见表姐为*的就是默认路由,已经配置完毕,下面我们在Area 0和Area 1进行下放默认路由。 R2(config)#router os 100
R2(config-router)#default-information originate
接下来分别在R1和R3上查看路由表:
R1#show ip route
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 12.1.1.2 to network 0.0.0.0
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/11] via 12.1.1.2, 00:10:14, FastEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/21] via 12.1.1.2, 00:10:14, FastEthernet0/0
4.0.0.0/32 is subnetted, 1 subnets
O E2 4.4.4.4 [110/20] via 12.1.1.2, 00:10:14, FastEthernet0/0
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.1.1.0 [110/20] via 12.1.1.2, 00:10:15, FastEthernet0/0
24.0.0.0/24 is subnetted, 1 subnets
O E2 24.1.1.0 [110/20] via 12.1.1.2, 00:10:15, FastEthernet0/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
O*E2 0.0.0.0/0 [110/1] via 12.1.1.2, 00:00:11, FastEthernet0/0
O IA 192.168.20.0/22 [110/21] via 12.1.1.2, 00:10:17, FastEthernet0/0
O E2 192.168.32.0/21 [110/20] via 12.1.1.2, 00:05:38, FastEthernet0/0
R3#show ip route
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 23.1.1.2 to network 0.0.0.0
1.0.0.0/32 is subnetted, 1 subnets
O IA 1.1.1.1 [110/21] via 23.1.1.2, 00:11:46, FastEthernet0/1
2.0.0.0/32 is subnetted, 1 subnets
O IA 2.2.2.2 [110/11] via 23.1.1.2, 00:11:46, FastEthernet0/1
3.0.0.0/32 is subnetted, 1 subnets
C 3.3.3.3 is directly connected, Loopback0
4.0.0.0/32 is subnetted, 1 subnets
O E2 4.4.4.4 [110/20] via 23.1.1.2, 00:11:46, FastEthernet0/1
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, FastEthernet0/1
C 192.168.21.0/24 is directly connected, Loopback2
24.0.0.0/24 is subnetted, 1 subnets
O E2 24.1.1.0 [110/20] via 23.1.1.2, 00:11:47, FastEthernet0/1
C 192.168.20.0/24 is directly connected, Loopback1
C 192.168.23.0/24 is directly connected, Loopback4
C 192.168.22.0/24 is directly connected, Loopback3
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.1.1.0 [110/20] via 23.1.1.2, 00:11:50, FastEthernet0/1
O*E2 0.0.0.0/0 [110/1] via 23.1.1.2, 00:01:46, FastEthernet0/1
O E2 192.168.32.0/21 [110/20] via 23.1.1.2, 00:07:12, FastEthernet0/1
我们都看到了O*E2的这条默认路由标记,因为下方的路由属于静态的路由,自然属于OSPF域外路由,所以标记为O E2,单又是默认路由,所以就是O*E2。
那如果我们没有在R2上配置默认路由,但我们想让其他设备将通往R2的路由设置为默认路由该如何进行配置呢?
首先我们将R2还原: R2(config)#no ip route 0.0.0.0 0.0.0.0 f1/0
R2(config)#router os 100
R2(config-router)#no default-information originate
之后我们再去R1看一下路由表:
R1#show ip route
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 not set
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/11] via 12.1.1.2, 00:16:32, FastEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/21] via 12.1.1.2, 00:16:32, FastEthernet0/0
4.0.0.0/32 is subnetted, 1 subnets
O E2 4.4.4.4 [110/20] via 12.1.1.2, 00:16:32, FastEthernet0/0
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.1.1.0 [110/20] via 12.1.1.2, 00:16:32, FastEthernet0/0
24.0.0.0/24 is subnetted, 1 subnets
O E2 24.1.1.0 [110/20] via 12.1.1.2, 00:16:34, FastEthernet0/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
O IA 192.168.20.0/22 [110/21] via 12.1.1.2, 00:16:34, FastEthernet0/0
O E2 192.168.32.0/21 [110/20] via 12.1.1.2, 00:11:54, FastEthernet0/0
默认路由消失,然后我们在OSPF进程下进行下放默认路由: R2(config-router)#default-information originate always
然后再去R1查看路由表:
R1#show ip route
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 12.1.1.2 to network 0.0.0.0
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/11] via 12.1.1.2, 00:18:07, FastEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/21] via 12.1.1.2, 00:18:07, FastEthernet0/0
4.0.0.0/32 is subnetted, 1 subnets
O E2 4.4.4.4 [110/20] via 12.1.1.2, 00:18:07, FastEthernet0/0
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.1.1.0 [110/20] via 12.1.1.2, 00:18:08, FastEthernet0/0
24.0.0.0/24 is subnetted, 1 subnets
O E2 24.1.1.0 [110/20] via 12.1.1.2, 00:18:08, FastEthernet0/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
O*E2 0.0.0.0/0 [110/1] via 12.1.1.2, 00:00:33, FastEthernet0/0
O IA 192.168.20.0/22 [110/21] via 12.1.1.2, 00:18:10, FastEthernet0/0
O E2 192.168.32.0/21 [110/20] via 12.1.1.2, 00:13:32, FastEthernet0/0
综上,共有两种方式下放默认路由:
- 在本地有默认路由的情况下
R2(config-router)#default-information originate
- 本地没有默认路由的情况下,强行下放默认路由
R2(config-router)#default-information originate always
默认cost=1并且是一个由LSA-5下放的