OSPF实验7:OSPF特殊区域
实验级别:
Professional
实验拓扑:
实验说明:
R2为ABR和ASBR,R3在NSSA实验时会成为ASBR。
在做这个实验之前,首先我们要了解一下
OSPF LSA
的类型。见下表:
类型代码
|
类型名称
|
描述
|
1
|
路由器
LSA
|
每台路由器都会产生,在区域内泛洪
|
2
|
网络
LSA
|
DR
产生,在区域内泛洪
|
3
|
网络汇总
LSA
|
ABR
始发,在整个
OSPF
域中泛洪
|
4
|
ASBR
汇总
LSA
|
ABR
始发,在整个
OSPF
域中泛洪
|
5
|
AS
外部
LSA
|
ASBR
始发,在整个
OSPF
域中泛洪
|
6
|
组成员
LSA
|
标识
OSPF
组播中的组成员,不做讨论
|
7
|
NSSA
外部
LSA
|
ASBR
始发,
|
8
|
外部属性
LSA
|
没有实现
|
9
|
Opaque LSA
(本地链路范围)
|
用于
MPLS
流量工程,不做讨论
|
10
|
Opaque LSA
(本地区域范围)
|
11
|
Opaque LSA
(
AS
范围)
|
在一个
OSPF
的普通区域,会存在
LSA1,LSA2,LSA3,LSA4,LSA5
这些
LSA
,并且数量很多。我们可以通过
OSPF
的特殊区域的配置让某些区域减少
LSA
数目和路由表的条目。
基本配置:
R1:
interface Loopback0
ip address 1.1.1.1 255.255.255.0
ip ospf network point-to-point
!
interface Serial1/0
ip address 10.1.1.1 255.255.255.0
serial restart-delay 0
!
router ospf 10
router-id 1.1.1.1
log-adjacency-changes
network 1.1.1.0 0.0.0.255 area 0
network 10.1.1.0 0.0.0.255 area 0
R2:
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface Serial1/0
ip address 10.1.1.2 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
ip address 11.1.1.1 255.255.255.0
serial restart-delay 0
!
router ospf 10
router-id 2.2.2.2
log-adjacency-changes
redistribute connected subnets
network 10.1.1.0 0.0.0.255 area 0
network 11.1.1.0 0.0.0.255 area 1
R3:
interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
interface FastEthernet0/0
no ip address
shutdown
duplex half
!
interface Serial1/0
ip address 11.1.1.2 255.255.255.0
serial restart-delay 0
!
router ospf 10
router-id 3.3.3.3
log-adjacency-changes
network 11.1.1.0 0.0.0.255 area 1
在
R1
和
R3
上查看路由表:
R1#sho ip rou
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/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/24 is subnetted, 1 subnets
O E2 2.2.2.0 [110/20] via 10.1.1.2, 00:03:00, Serial1/0
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Serial1/0
11.0.0.0/24 is subnetted, 1 subnets
O IA 11.1.1.0 [110/128] via 10.1.1.2, 00:03:00, Serial1/0
R3#sho ip rou
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/24 is subnetted, 1 subnets
O IA 1.1.1.0 [110/129] via 11.1.1.1, 00:02:51, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
O E2 2.2.2.0 [110/20] via 11.1.1.1, 00:02:51, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 1 subnets
O IA 10.1.1.0 [110/128] via 11.1.1.1, 00:02:51, Serial1/0
11.0.0.0/24 is subnetted, 1 subnets
C 11.1.1.0 is directly connected, Serial1/0
OE2
的路由是通过
LSA5
传播,
OIA
的路由是通过
LSA3
来传播。
1. Stub Area
我们观察拓扑,发现
Area1
不管去外部的那个目的网络,都必须通过
ABR R2
进行转发。在这种情况下,
Area1
可以配置成
Stub Area
。
Stub Area
可以阻止
LSA5
,,并且处在区域边界的
ABR
将会通过
LSA3
发送一个默认路由给
Stub Area
。处在
Stub Area
内的所有路由器都必须配置成为
Stub Area
。
首先查看
R3
的
OSPF
数据库
R3#sho ip ospf da
OSPF Router with ID (3.3.3.3) (Process ID 10)
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count
2.2.2.2 2.2.2.2 9 0x80000007 0x00309C 1
3.3.3.3 3.3.3.3 1 0x80000006 0x00451E 2
Summary Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
0.0.0.0 2.2.2.2 199 0x80000001 0x0075C0
1.1.1.0 2.2.2.2 9 0x80000003 0x00B13D
10.1.1.0 2.2.2.2 9 0x80000003 0x0032B4
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
2.2.2.0 2.2.2.2 842 0x80000001 0x00632F 0
通过以下配置可以将
Area1
配置成为
Stub Area
。
R2(config)#router ospf 10
R2(config-router)#area 1 stub
R3(config)#router ospf 10
R3(config-router)#area 1 stub
在
R3
上查看路由表:
R3#sho ip rou
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 11.1.1.1 to network 0.0.0.0
1.0.0.0/24 is subnetted, 1 subnets
O IA 1.1.1.0 [110/129] via 11.1.1.1, 00:00:16, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 1 subnets
O IA 10.1.1.0 [110/128] via 11.1.1.1, 00:00:16, Serial1/0
11.0.0.0/24 is subnetted, 1 subnets
C 11.1.1.0 is directly connected, Serial1/0
O*IA 0.0.0.0/0 [110/65] via 11.1.1.1, 00:00:16, Serial1/0
发现原来的
OE2
路由没有了,取代了
1
条默认路由
O*IA 0.0.0.0/0 [110/65]
(通过
LSA3
通告)
在看
R3
的
OSPF
数据库
R3#sho ip ospf da
OSPF Router with ID (3.3.3.3) (Process ID 10)
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count
2.2.2.2 2.2.2.2 7 0x8000000A 0x00BEA6 2
3.3.3.3 3.3.3.3 6 0x80000008 0x005F04 2
Summary Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
0.0.0.0 2.2.2.2 12 0x80000001 0x0075C0
1.1.1.0 2.2.2.2 12 0x80000004 0x00CD22
10.1.1.0 2.2.2.2 12 0x80000004 0x004E9
此时已经没有
Type-5 AS External Link States
的
LSA
了。
2. Totally Stub Area
对于本实验的
Area1
来说,其实域间路由
OIA
也是不需要的。我们可以将
Area1
配置成为
Totally Stub Area
,从而来阻止
LSA3
和
LSA4
在这个区域的传播
,
出了通告缺省路由的那一条类型
3
的
LSA
。
Totally Stub Area
的配置也很简单,只需要在
ABR
上将其配置成为
totally stub area
,并且这个区域的所有路由器配置成为
stub area
就可以了。
在这个实验中,我们在上面已经将
R3
配置成
stub area
,只要在
R2
上配置
area1
成为
Totally Stub Area
即可。
R2(config-router)#area 1 stub no-summary
在
R3
上查看路由表和数据库
R3#sho ip rou
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 11.1.1.1 to network 0.0.0.0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
11.0.0.0/24 is subnetted, 1 subnets
C 11.1.1.0 is directly connected, Serial1/0
O*IA 0.0.0.0/0 [110/65] via 11.1.1.1, 00:00:12, Serial1/0
发现
OIA
的路由条目也没有了
R3#sho ip ospf database
OSPF Router with ID (3.3.3.3) (Process ID 10)
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count
2.2.2.2 2.2.2.2 415 0x8000000A 0x00BEA6 2
3.3.3.3 3.3.3.3 415 0x80000008 0x005F04 2
Summary Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
0.0.0.0 2.2.2.2 69 0x80000002 0x0073C1
只有
LSA1
和一条汇总的
LSA3
3. Not-So-Stubby Area(NSSA)
如果我们需要
R3
通过重发布来发布它的直连路由,这样
R3
就是一个
ASBR
路由器,会产生
LSA7
。但是一旦这样,
R3
就不能是一个
Stub Area
。这时我们可以将
Area 1
配置成为
NSSA
区域。
NSSA
:允许外部路由通告到
OSPF
,而同时保留其余部分的
Stub Area
特征。
NSSA
区域是在
IOS
软件
11.2
版本以上才支持的。
配置
NSSA
:
首先重发布
R3
的直连路由
R3(config-router)#redistribute connected subnets
Warning: Router is currently an ASBR while having only one area which is a stub area
这里有一个警告信息,告诉我们在一个
Stub Area
上不能有路由器是
ASBR
,这样重发布是不起作用的。
我们将原来的配置删除:
R3(config-router)#router ospf 10
R3(config-router)#no area 1 stub
R2(config-router)#no area 1 stub
查看
R1
和
R3
的路由表
R1#sho ip rou
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/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/24 is subnetted, 1 subnets
O E2 2.2.2.0 [110/20] via 10.1.1.2, 00:00:01, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
O E2 3.3.3.0 [110/20] via 10.1.1.2, 00:00:01, Serial1/0
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Serial1/0
11.0.0.0/24 is subnetted, 1 subnets
O IA 11.1.1.0 [110/128] via 10.1.1.2, 00:35:32, Serial1/0
已经学到了
R3
的环回口路由
R3#sho ip rou
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/24 is subnetted, 1 subnets
O IA 1.1.1.0 [110/129] via 11.1.1.1, 00:00:53, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
O E2 2.2.2.0 [110/20] via 11.1.1.1, 00:00:53, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 1 subnets
O IA 10.1.1.0 [110/128] via 11.1.1.1, 00:00:53, Serial1/0
11.0.0.0/24 is subnetted, 1 subnets
C 11.1.1.0 is directly connected, Serial1/0
有
OIA
和
OE2
的路由
现在将
Area1
配置成为
NSSA
区域
R2(config)#router os 10
R2(config-router)#area 1 nssa
R3(config)#router ospf 10
R3(config-router)#area 1 nssa
查看
R3
的路由表
R3#sho ip rou
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/24 is subnetted, 1 subnets
O IA 1.1.1.0 [110/129] via 11.1.1.1, 00:00:56, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
O N2 2.2.2.0 [110/20] via 11.1.1.1, 00:00:56, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 1 subnets
O IA 10.1.1.0 [110/128] via 11.1.1.1, 00:00:56, Serial1/0
11.0.0.0/24 is subnetted, 1 subnets
C 11.1.1.0 is directly connected, Serial1/0
多了一条
O N2 2.2.2.0 [110/20]
,
ON2
表示
OSPF NSSA
外部路由。这时
R2
(即是
ABR
也是
ASBR
)通过
LSA7
向
R3
注入的外部路由。
我们可以将它去除。
R2(config-router)#area 1 nssa no-redistribution
再次查看
R3
路由表
R3#sho ip rou
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/24 is subnetted, 1 subnets
O IA 1.1.1.0 [110/129] via 11.1.1.1, 00:02:35, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 1 subnets
O IA 10.1.1.0 [110/128] via 11.1.1.1, 00:02:35, Serial1/0
11.0.0.0/24 is subnetted, 1 subnets
C 11.1.1.0 is directly connected, Serial1/0
已经没有
ON2
的路由了,但是我们发现一个问题,就是路由表中也没有默认路由。因为
NSSA
区域默认情况下,
ABR
是不会注入默认路由
。要注入默认路由,需要如下配置:
R2(config-router)#area 1 nssa default-information-originate
查看
R3
路由表
R3#sho ip rou
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 11.1.1.1 to network 0.0.0.0
1.0.0.0/24 is subnetted, 1 subnets
O IA 1.1.1.0 [110/129] via 11.1.1.1, 00:04:06, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 1 subnets
O IA 10.1.1.0 [110/128] via 11.1.1.1, 00:04:06, Serial1/0
11.0.0.0/24 is subnetted, 1 subnets
C 11.1.1.0 is directly connected, Serial1/0
O*N2 0.0.0.0/0 [110/1] via 11.1.1.1, 00:00:18, Serial1/0
有一条
ON2
的默认路由了。
4. Totally NSSA
和
Totally Stub Area
一样,同样可以通过配置将
OIA
的路由去除。配置如下:
R2(config-router)#area 1 nssa no-summary
查看
R3
路由表:
R3#sho ip rou
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 11.1.1.1 to network 0.0.0.0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
11.0.0.0/24 is subnetted, 1 subnets
C 11.1.1.0 is directly connected, Serial1/0
O*IA 0.0.0.0/0 [110/65] via 11.1.1.1, 00:00:16, Serial1/0
只有一条默认路由了。
注意:在配置成为
Totally NSSA
后,不需要加上
default-information-originate
这个参数,也能产生默认路由。
总结:
OSPF
的特殊区域可以总结成为下表:
区域类型
|
LSA1
|
LSA2
|
LSA3
|
LSA4
|
LSA5
|
LSA7
|
普通区域
|
★
|
★
|
★
|
★
|
★
|
|
Stub
|
★
|
★
|
★
|
|
|
|
Totally Stub
|
★
|
★
|
|
|
|
|
NSSA
|
★
|
★
|
★
|
|
|
★
|
Totally NSSA
|
★
|
★
|
|
|
|
★
|
★
表示存在此种类型的
LSA