前几篇文章我写了关于ospf的lsa文章,这次我们就实例配置下,我们边做实验便解释
我们先不配r6 ,我们先完成初始配置布置好路由协议
r1:interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface Ethernet0/0
ip address 192.168.1.1 255.255.255.0
half-duplex
!
interface Ethernet0/1
ip address 192.168.2.1 255.255.255.0
half-duplex
router ospf 10
router-id 1.1.1.1
log-adjacency-changes
network 1.1.1.1 0.0.0.0 area 0
network 192.168.1.0 0.0.0.255 area 1
network 192.168.2.0 0.0.0.255 area 0
r2:interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface Ethernet0/0
ip address 192.168.1.2 255.255.255.0
router ospf 10
router-id 2.2.2.2
log-adjacency-changes
network 2.2.2.2 0.0.0.0 area 1
network 192.168.1.0 0.0.0.255 area 1
r3:interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
interface Ethernet0/0
ip address 192.168.3.3 255.255.255.0
half-duplex
!
interface Ethernet0/1
ip address 192.168.2.3 255.255.255.0
router ospf 10
router-id 3.3.3.3
network 3.3.3.3 0.0.0.0 area 0
network 192.168.2.0 0.0.0.255 area 0
network 192.168.3.0 0.0.0.255 area 2
r4: interface Loopback0
ip address 4.4.4.4 255.255.255.0
!
interface Ethernet0/0
ip address 192.168.3.4 255.255.255.0
half-duplex
!
interface Ethernet0/1
ip address 192.168.4.4 255.255.255.0
router ospf 10
router-id 4.4.4.4
network 4.4.4.4 0.0.0.0 area 2
network 192.168.3.0 0.0.0.255 area 2
network 192.168.4.0 0.0.0.255 area 3
r5: interface Loopback0
ip address 5.5.5.5 255.255.255.0
interface Ethernet0/1
ip address 192.168.4.5 255.255.255.0router ospf 10
router-id 5.5.5.5
log-adjacency-changes
network 5.5.5.5 0.0.0.0 area 3
network 192.168.4.0 0.0.0.255 area 3
好我们看下r1和r5路由表
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/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 192.168.1.2, 00:16:42, Ethernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/11] via 192.168.2.3, 00:00:09, Ethernet0/1
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/21] via 192.168.2.3, 00:00:09, Ethernet0/1
C 192.168.1.0/24 is directly connected, Ethernet0/0
C 192.168.2.0/24 is directly connected, Ethernet0/1
O IA 192.168.3.0/24 [110/20] via 192.168.2.3, 00:00:09, Ethernet0/1
r5#show 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
5.0.0.0/24 is subnetted, 1 subnets
C 5.5.5.0 is directly connected, Loopback0
C 192.168.4.0/24 is directly connected, Ethernet0/1
我们发现r5学不到r1的路由,因为区域3没有和骨干区域相连没有lsa3的通告,所以看不到我们可以布置虚链路,虚链路的实质就是把r3 r4看成一个骨干路由这样区域3内就有lsa3通告了虚链路:
a) OSPF多域配置时的限制:骨干区域area 0必须存在;非骨干区域之间通信时都必须先连接到骨干区域
b) 当OSPF网络已经设计好后,有新的区域添加进来,可能会产生这样的情况:不可能通过直连链路连接到骨干区域,为了符合要求,虚链路被提了出来
配置虚链路的几条相关的规则:
a) 虚链路必须配置在两台ABR路由器之间
b) 配置了虚链路所经过的区域必须拥有全部的路由选择信息,这样的区域又被称为传送区域 (Transit Area)
c) 传送区域不能是一个末梢区域
配置:
Router(config-router)# area area-id virtual-link 对方邻居的 router-id (在两边的 ABR 上都要配置)
使用命令 show ip ospf virtual-link 可以查看一条虚链路的状态
我们添加命令
r3(config-router)#area 10 virtual-link 4.4.4.4
r4(config-router)#area 2 virtual-link 3.3.3.3
我们在看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/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 192.168.1.2, 00:22:25, Ethernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/11] via 192.168.2.3, 00:05:42, Ethernet0/1
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/21] via 192.168.2.3, 00:05:42, Ethernet0/1
5.0.0.0/32 is subnetted, 1 subnets
O IA 5.5.5.5 [110/31] via 192.168.2.3, 00:05:42, Ethernet0/1
O IA 192.168.4.0/24 [110/30] via 192.168.2.3, 00:05:42, Ethernet0/1
C 192.168.1.0/24 is directly connected, Ethernet0/0
C 192.168.2.0/24 is directly connected, Etr5#show 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/32 is subnetted, 1 subnets
O IA 1.1.1.1 [110/31] via 192.168.4.4, 00:00:18, Ethernet0/1
2.0.0.0/32 is subnetted, 1 subnets
O IA 2.2.2.2 [110/41] via 192.168.4.4, 00:00:18, Ethernet0/1
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/21] via 192.168.4.4, 00:00:18, Ethernet0/1
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/11] via 192.168.4.4, 00:00:37, Ethernet0/1
5.0.0.0/24 is subnetted, 1 subnets
C 5.5.5.0 is directly connected, Loopback0
C 192.168.4.0/24 is directly connected, Ethernet0/1
O IA 192.168.1.0/24 [110/40] via 192.168.4.4, 00:00:18, Ethernet0/1
O IA 192.168.2.0/24 [110/30] via 192.168.4.4, 00:00:18, Ethernet0/1
O IA 192.168.3.0/24 [110/20] via 192.168.4.4, 00:00:42, Ethernet0/1hernet0/1
r5学到了,我们仔细比较下r1的路由表在添加虚链路前后,看看能发现什么 呵呵
在Stub区域中规定不接收外部AS的LSA,也不向外部AS发送区域内部LSA,即Stub区域中不注入ASE(自治系统外部)路由。Stub区域一定是非骨干区域和非转换区域(可以配置虚连接的区域),因为它不接收也不发送LSA。并且在Stub区域中不传递Type 5类型(AS外部LSA)的LSA,我们可以把区域1配置成末梢区域
r2(config-router)#area 1 stub
r1(config-router)#area 1 stub
现在我们把r6加进来,r6运行rip协议但这样区域1就不满足stub区域的条件了,但区域1又想保持stub区域的特征我们可以把区域1配置为nssa区域,NSSA区域规定,AS外的ASE路由不可以进入到NSSA区域中,但是NSSA区域内的路由器引入的ASE路由(NSSA区域中可以连接ASBR)可以在NSSA中泛洪并发送到区域之外。这样,在NSSA区域中取消了原来Stub区域中关于ASE的双向传播的限制(区域外的进不来,区域里的也出不去),改为单向限制(区域外的进不来,区域里的能出去)。若要定义NSSA区域,使用OSPF路由器配置命令“area xx nssa”命令, 非纯末梢区域 NSSA: Router(config-router)# area area-id nssa a) 允许有自己的 ASBR,一旦有 ASBR,实际有就有 LSA-5,但 NSSA 不允许 LSA-5,所以 LSA-5 就变成了 LSA-7 ; b) NSSA区域对外部的路由条目为 O N2,之后 ABR 将 LSA-7 转换为 LSA-5 发送。 非纯末梢区域 NSSA: Router(config-router)# area area-id nssa
a) 允许有自己的 ASBR,一旦有 ASBR,实际有就有 LSA-5,但 NSSA 不允许 LSA-5,所以 LSA-5 就变成了 LSA-7 ;
b) NSSA区域对外部的路由条目为 O N2,之后 ABR 将 LSA-7 转换为 LSA-5 发送出去。(在别的区域对于这条路由条目为 O E2);
c) NSSA区域有区域间的路由条目 O IA;
d) 如果希望去往其它的外部路由,要手工注入一条默认路由。
在进程下, area area-id nssa default-information-originate (在NSSA区域的 ABR 上去配置)
* 只有NSSA区域要手工注入一条默认路由,而其它区域(Stub,Totally Stubby,Totally NSSA)会自动生成一条默认路由。
r1(config-router)#area 1 nssa
r2(config-router)#area 1 nssa
r2(config-router)# router rip
r2(config-router)#network 192.168.5.0
r2(config-router)#router ospf 10
r2(config-router)#redistribute rip metric 10 metric-type 1 subnets
r6(config-if)#int s0/1
r6(config-if)#ip add 192.168.5.6 255.255.255.0
r6(config-if)#router rip
r6(config-router)#ver
r6(config-router)#version 2
r6(config-router)#net
r6(config-router)#network 192.168.5.0
r6(config-router)#net
r6(config-router)#network 6.6.6.0
r6(config-router)#no au
好我们看下r2路由表
r2:r2#show 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/32 is subnetted, 1 subnets
O IA 1.1.1.1 [110/11] via 192.168.1.1, 00:00:41, Ethernet0/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 IA 3.3.3.3 [110/21] via 192.168.1.1, 00:00:41, Ethernet0/0
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/31] via 192.168.1.1, 00:00:41, Ethernet0/0
5.0.0.0/32 is subnetted, 1 subnets
O IA 5.5.5.5 [110/41] via 192.168.1.1, 00:00:41, Ethernet0/0
6.0.0.0/24 is subnetted, 1 subnets
R 6.6.6.0 [120/1] via 192.168.5.6, 00:00:08, Serial1/0
O IA 192.168.4.0/24 [110/40] via 192.168.1.1, 00:00:41, Ethernet0/0
C 192.168.5.0/24 is directly connected, Serial1/0
C 192.168.1.0/24 is directly connected, Ethernet0/0
O IA 192.168.2.0/24 [110/20] via 192.168.1.1, 00:00:43, Ethernet0/0
O IA 192.168.3.0/24 [110/30] via 192.168.1.1, 00:00:43, Ethernet0/0
r2#show ip ospf database database-summary 我们看下lsa
OSPF Router with ID (2.2.2.2) (Process ID 10)
Area 1 database summary
LSA Type Count Delete Maxage
Router 2 0 0
Network 1 0 0
Summary Net 7 0 0
Summary ASBR 0 0 0
Type-7 Ext 2 0 0
Prefixes redistributed in Type-7 2
Opaque Link 0 0 0
Opaque Area 0 0 0
Subtotal 12 0 0
Process 10 database summary
LSA Type Count Delete Maxage
Router 2 0 0
Network 1 0 0
Summary Net 7 0 0
Summary ASBR 0 0 0
Type-7 Ext 2 0 0
Opaque Link 0 0 0
路由汇总:我们在路由5上加上几个回环口ip
r5(config-if)#int lo 1
r5(config-if)#ip add 5.5.1.5 255.255.255.0
r5(config-if)#int lo 2
r5(config-if)#ip add 5.5.2.5 255.255.255.0
r5(config-if)#int lo 3
r5(config-if)#ip add 5.5.3.5 255.255.255.0
r5(config-if)#router ospf 10 把他宣告进去
r5(config-router)#net
r5(config-router)#network 5.5.1.5 0.0.0.0 a 3
r5(config-router)#network 5.5.2.5 0.0.0.0 a 3
r5(config-router)#network 5.5.3.5 0.0.0.0 a 3
我们看下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
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/21] via 192.168.3.3, 00:10:21, Ethernet0/0
2.0.0.0/32 is subnetted, 1 subnets
O IA 2.2.2.2 [110/31] via 192.168.3.3, 00:00:11, Ethernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/11] via 192.168.3.3, 00:10:21, Ethernet0/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
5.0.0.0/32 is subnetted, 4 subnets
O 5.5.5.5 [110/11] via 192.168.4.5, 00:00:11, Ethernet0/1
O 5.5.1.5 [110/11] via 192.168.4.5, 00:00:11, Ethernet0/1
O 5.5.3.5 [110/11] via 192.168.4.5, 00:00:11, Ethernet0/1
O 5.5.2.5 [110/11] via 192.168.4.5, 00:00:11, Ethernet0/1
6.0.0.0/24 is subnetted, 1 subnets
O E1 6.6.6.0 [110/41] via 192.168.3.3, 00:00:12, Ethernet0/0
C 192.168.4.0/24 is directly connected, Ethernet0/1
O E1 192.168.5.0/24 [110/41] via 192.168.3.3, 00:00:12, Ethernet0/0
O IA 192.168.1.0/24 [110/30] via 192.168.3.3, 00:00:12, Ethernet0/0
O 192.168.2.0/24 [110/20] via 192.168.3.3, 00:10:23, Ethernet0/0
C 192.168.3.0/24 is directly connected, Ethernet0/0
地址汇总:地址汇总也是通过减少泛洪的LSA数量节省资源;可以通过屏蔽一些网络不稳定的细节来节省资源
怎样算网络号、正/反掩码?--> 设计时,第一个地址最好为偶数,最后一个地址最好为奇数。
a) 第一位不同的地址为偶数,最后一位不同的地址为奇数; e.g,172.16.16.x~172.16.23.x
b) 将第一位不同IP地址转换为二进制;
c) 把二进制第一位不相同的找出来;
d) 网络号计算:相同的照写,不同的用 0 表示,并转换为十进制;(0 表示匹配所有,对照缺省路由想想)
e) 正掩码计算:相同部分写 1,不同的用 0 表示;(1 表示检查,0 表示不检查)
f) 反掩码计算:相同部分写 0,不同的用 1 表示;(0 表示检查,1 表示不检查) 反掩码也叫通配符掩码,可以为不连续的 1
区域间路由汇总:Router(config-router)# area area-id range 网络号 正掩码 (在ABR上配置)
外部路由汇总: Router(config-router)# summary-address 网络号 正掩码 (在ASBR上配置)
使用 no summary-address 命令可以恢复默认值
本文出自 “cisco network” 博客,谢绝转载!