OSPF特殊區域
OSPF特殊區域
Stub末節區域
OSPF的stub標識的區域成為stub末節區域,在此區域內,過濾外部來的LSA-4和LSA-5,即stub區域不接受自治系統外部的路由資訊,若需要路由到自治系統外部網路,需要通過預設路由(0.0.0.0)來實現,在stub區域內不存在ASBR(過濾了LSA-5)。
配置命令:area 1 stub(需要在區域內的路由器全部配置)
配置成功後,ABR會自動下放預設路由,若有一個或多個ABR的時候,可能有多條預設路由,根據cost值優先選路。
區域0 不可以配置stub標識。
Stub區域不能有虛鏈路穿過。
Stub配置演示
我們用上面拓撲圖為例,我們將區域1配置為stub
在R1上配置:
R1>en
R1#conf t
R1(config)#int lo 0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#exi
R1(config)#int lo 1
R1(config-if)#ip add 10.1.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#exi
R1(config)#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 eigrp 90
R1(config-router)#no au
R1(config-router)#net 10.1.1.1 0.0.0.255
R1(config-router)#net 1.1.1.1 0.0.0.255
R1(config-router)#exi
R1(config)#router os 100
R1(config-router)#router-id 1.1.1.1
R1(config-router)#net 12.1.1.1 0.0.0.255 a 1
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.0
R2(config-if)#no sh
R2(config-if)#exi
R2(config)#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)#router os 100
R2(config-router)#router-id 2.2.2.2
R2(config-router)#net 12.1.1.2 0.0.0.255 a 1
R2(config-router)#net 23.1.1.2 0.0.0.255 a 0
R2(config-router)#net 2.2.2.2 0.0.0.255 a 1
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.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)#int f0/0
R3(config-if)#ip add 34.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 23.1.1.3 0.0.0.255 a 0
R3(config-router)#net 3.3.3.3 0.0.0.255 a 0
R3(config-router)#net 34.1.1.3 0.0.0.255 a 2
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.0
R4(config-if)#no sh
R4(config-if)#exi
R4(config)#int f0/0
R4(config-if)#ip add 34.1.1.4 255.255.255.0
R4(config-if)#no sh
R4(config-if)#exi
R4(config)#int lo 1
R4(config-if)#ip add 40.1.1.1 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 34.1.1.4 0.0.0.255 a 2
R4(config-router)#exi
R4(config)#router rip
R4(config-router)#v 2
R4(config-router)#no au
R4(config-router)#net 4.4.4.0
R4(config-router)#net 40.1.1.0
R4(config-router)#exi
我們在R1和R4上進行重分發:
R1(config)#router os 100
R1(config-router)#redistribute eigrp 90 subnets
R1(config-router)#exi
R1(config)#router ei 90
R1(config-router)#redistribute ospf 100 metric 1000 10 255 1 1000
R1(config-router)#exi
R4(config)#router os 100
R4(config-router)#redistribute rip subnets
R4(config-router)#exi
R4(config)#router rip
R4(config-router)#redistribute ospf 1
R4(config-router)#exi
接下來我們在R1和R2上檢視一下路由表:
R1(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 not set
34.0.0.0/24 is subnetted, 1 subnets
O IA 34.1.1.0 [110/30] via 12.1.1.2, 00:01:47, FastEthernet0/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/11] via 12.1.1.2, 00:01:47, 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:47, FastEthernet0/0
4.0.0.0/24 is subnetted, 1 subnets
O E2 4.4.4.0 [110/20] via 12.1.1.2, 00:00:33, 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:49, FastEthernet0/0
40.0.0.0/24 is subnetted, 1 subnets
O E2 40.1.1.0 [110/20] via 12.1.1.2, 00:00:35, FastEthernet0/0
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Loopback1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/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 not set
34.0.0.0/24 is subnetted, 1 subnets
O IA 34.1.1.0 [110/20] via 23.1.1.3, 00:01:58, FastEthernet0/1
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 12.1.1.1, 00:00:44, FastEthernet0/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/11] via 23.1.1.3, 00:02:45, FastEthernet0/1
4.0.0.0/24 is subnetted, 1 subnets
O E2 4.4.4.0 [110/20] via 23.1.1.3, 00:00:44, FastEthernet0/1
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, FastEthernet0/1
40.0.0.0/24 is subnetted, 1 subnets
O E2 40.1.1.0 [110/20] via 23.1.1.3, 00:00:47, FastEthernet0/1
10.0.0.0/24 is subnetted, 1 subnets
O E2 10.1.1.0 [110/20] via 12.1.1.1, 00:00:48, FastEthernet0/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
ok和預期一樣,接下來進行stub區域的配置,我們將區域1配置為stub:
R1(config)#router os 100
R1(config-router)#area 1 stub
R2(config)#router os 100
R2(config-router)#ar 1 st
稍等一下等收斂完成後我們再檢視一下路由表
R1(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 12.1.1.2 to network 0.0.0.0
34.0.0.0/24 is subnetted, 1 subnets
O IA 34.1.1.0 [110/30] via 12.1.1.2, 00:00:01, FastEthernet0/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/11] via 12.1.1.2, 00:00:01, 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:00:01, 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:00:03, FastEthernet0/0
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Loopback1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
O*IA 0.0.0.0/0 [110/11] via 12.1.1.2, 00:00:05, FastEthernet0/0
R2#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
34.0.0.0/24 is subnetted, 1 subnets
O IA 34.1.1.0 [110/20] via 23.1.1.3, 00:01:09, FastEthernet0/1
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/11] via 23.1.1.3, 00:01:24, FastEthernet0/1
4.0.0.0/24 is subnetted, 1 subnets
O E2 4.4.4.0 [110/20] via 23.1.1.3, 00:01:09, FastEthernet0/1
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, FastEthernet0/1
40.0.0.0/24 is subnetted, 1 subnets
O E2 40.1.1.0 [110/20] via 23.1.1.3, 00:01:12, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
我們可以看見,Area 1配置為stub區域之後,所有的外部路由都傳不進來了,R2丟失了通過R1去往EIGRP區域的路由,R1丟失了R2傳過來的去往RIP的路由,但由於R2是ABR,會給R1一條去往自己的預設路由。由於R2不只是在一個區域之中,所以並不會丟失區域0接收到的去往RIP的路由。
Totally-Stub完全末節區域
OSPF的完全末節區域是思科私有的,過濾LSA-3、LSA-4、LSA-5三個LSA,也就是說不只是自治系統外部的路由,就連自治系統內部其他區域的路由也同樣不接受。如果完全末節區域內想要路由至完全末節區域外的話也需要通過預設路由(0.0.0.0)來實現。
配置命令:area 1 stub no-summary(只需要在ABR上配置即可)
配置成後,ABR會自動下放預設路由。
Totally-Stub完全末節區域的配置
我們還是用剛才的拓撲圖,也是將區域1配置為Totally-Stub:
在R2上進行配置就可以了:
R2(config)#router os 100
R2(config-router)#area 1 stub no-summary
接下來在R1和R2上檢視路由表
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/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/11] via 12.1.1.2, 00:02:04, FastEthernet0/0
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Loopback1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
O*IA 0.0.0.0/0 [110/11] via 12.1.1.2, 00:00:06, FastEthernet0/0
R2#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
34.0.0.0/24 is subnetted, 1 subnets
O IA 34.1.1.0 [110/20] via 23.1.1.3, 00:00:48, FastEthernet0/1
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/11] via 23.1.1.3, 00:00:48, FastEthernet0/1
4.0.0.0/24 is subnetted, 1 subnets
O E2 4.4.4.0 [110/20] via 23.1.1.3, 00:00:48, FastEthernet0/1
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, FastEthernet0/1
40.0.0.0/24 is subnetted, 1 subnets
O E2 40.1.1.0 [110/20] via 23.1.1.3, 00:00:50, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
和stub類似,R1不只是失去了OE2的路由,並且失去了OIA的路由,但同樣的,它獲得了自己的ABR下發的一條預設路由。同時R2也失去了去往EIGRP區域的路由,但沒有失去區域0收到的去往RIP的路由。
NSSA Not-So-Stubby-Area
OSPF的NSSA區域是一個在Stub區域的基礎上有一些微小的變化,它過濾LSA-4和LSA-5並且允許有ASBR。向NSSA中重分發會產生LSA-7,這類LSA只存在NSSA中,並且只有NSSA的ASBR會產生LSA-7,在NSSA中需要在ABR上進行配置才會下放預設路由。
配置命令:area 1 nssa default-information-originate
在上面拓撲圖中,Area2被配置成了NSSA區域,在NSSA區域內的R4裝置接收到的R1EIGRP部分的重分發會被標記為N2,而R3接收到R4重分發的RIPV2的路由條目也會被標記為N2,但R1和R2接收到的RIPV2的路由確實E2標記,這裡涉及到“NSSA中的ABR會進行一個叫做七轉五的操作,將LSA-7轉換為LSA-5”所以在這個拓撲中R3就是進行七轉五的ABR,所以在R1和R2上面觀察到的RIPV2的ASBR是R3。
NSSA的配置
我們就用剛才的拓撲圖,先將Area1還原,再將Area2配置為NSSA區域:
R1(config)#router os 100
R1(config-router)#no area 1 stub
R2(config)#router os 100
R2(config-router)#no ar 1 st no
R2(config-router)#no ar 1 st
R2(config-router)#exi
NSSA配置:
R3(config)#router os 100
R3(config-router)#ar 2 nssa
R4(config)#router os 100
R4(config-router)#ar 2 nssa
接下來我們在R3和R4上檢視路由表:
R4#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
34.0.0.0/24 is subnetted, 1 subnets
C 34.1.1.0 is directly connected, FastEthernet0/0
2.0.0.0/32 is subnetted, 1 subnets
O IA 2.2.2.2 [110/21] via 34.1.1.3, 00:02:16, FastEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/11] via 34.1.1.3, 00:02:16, FastEthernet0/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.1.1.0 [110/20] via 34.1.1.3, 00:02:16, FastEthernet0/0
40.0.0.0/24 is subnetted, 1 subnets
C 40.1.1.0 is directly connected, Loopback1
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.1.1.0 [110/30] via 34.1.1.3, 00:02:20, FastEthernet0/0
Nssa區域會過濾LSA-4和LSA-5但允許擁有ASBR,所以在R4上看路由表,它失去了去往EIGRP區域的路由,但由於直連的關係,並沒有失去RIP區域的路由,而且在我們沒有配置之前,R4上並沒有自動下放的預設路由。然後在R3上檢視路由表:
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 not set
34.0.0.0/24 is subnetted, 1 subnets
C 34.1.1.0 is directly connected, FastEthernet0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 23.1.1.2, 00:02:47, 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:02:47, FastEthernet0/1
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
4.0.0.0/24 is subnetted, 1 subnets
O N2 4.4.4.0 [110/20] via 34.1.1.4, 00:02:47, FastEthernet0/0
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, FastEthernet0/1
40.0.0.0/24 is subnetted, 1 subnets
O N2 40.1.1.0 [110/20] via 34.1.1.4, 00:02:51, FastEthernet0/0
10.0.0.0/24 is subnetted, 1 subnets
O E2 10.1.1.0 [110/20] via 23.1.1.2, 00:02:52, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.1.1.0 [110/20] via 23.1.1.2, 00:02:53, FastEthernet0/1
再R3上檢視路由表,我們會發現,由於R3不只是屬於一個區域,所以並沒有失去OE2的去往EIGRP區域的路由,但卻多了兩條標記為ON2的去往RIP區域的路由,這是由於nssa區域允許存在ASBR,而NSSA區域的ASBR宣告的外部路由會被標記為ASBR,但我們上面介紹過,ON2這種標記只存在於NSSA區域,當這種外部路由發往其他區域的時候,會在ABR上進行一種叫做七轉五的操作,在這張拓撲圖中,進行七轉五的就是R3。所以我們預測不差的話, 在R1上檢視路由表,依舊會看見標記為OE2的去往RIP區域的路由。那麼下面我們來驗證一下:
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
34.0.0.0/24 is subnetted, 1 subnets
O IA 34.1.1.0 [110/30] via 12.1.1.2, 00:10:59, FastEthernet0/0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/32