试验所用拓扑如下:
拓扑介绍:
分为Area 0 Area 1 和Area 2三个区域。R1的全部和R2的S0/0属于Area 1;r2的S0/1和R3的S0/0属于Area 0;R3的S0/1和R4的全部属于Area 2.每个路由器都设置有一个loop端口。
好了,让我们从OSPF的网络类型开始:
OSPF的网络类型
在上一篇文章中我们提到过:根据路由器所连接的物理网络不同,OSPF将网络划分为四种类型:
点到点型(Point-to-Point)、点到多点型(Point-to-MultiPoint)、广播多路访问型(Broadcast multiAccess)、非广播多路访问型(None Broadcast MultiAccess,NBMA)
多区域的OSPF其实很简单,只要注意正确分配网络到特定区域就OK了!
配置步骤如下:(路由器的基本配置省略)
R1
r1(config)#router ospf 100
r1(config-router)#network 192.168.1.0 0.0.0.255 area 1 分配网络到特定区域
r1(config-router)#network 172.16.1.0 0.0.0.255 area 1
r1(config-router)#network 10.1.1.0 0.0.0.255 area 1
r2(config)#router ospf 100
r2(config-router)#network 192.168.1.0 0.0.0.255 area 1 分配网络到特定区域
r2(config-router)#network 192.168.2.0 0.0.0.255 area 0
r2(config-router)#network 20.1.1.0 0.0.0.255 area1
R3
r3(config)#router ospf 100
r3(config-router)#network 192.168.2.0 0.0.0.255 area 0 分配网络到特定区域
r3(config-router)#network 192.168.3.0 0.0.0.255 area 2
r3(config-router)#network 30.1.1.0 0.0.0.255 area 0
r4(config)#router ospf 100
r4(config-router)#network 192.168.3.0 0.0.0.255 area 2 分配网络到特定区域
r4(config-router)#network 172.16.100.0 0.0.0.255 area 2
r4(config-router)#network 40.1.1.0 0.0.0.255 area 2
验证点到点OSPF的配置,PC1 和PC2之间能相互通讯。配置成功!
VPCS 1 >ping 172.16.100.2
172.16.100.2 icmp_seq=1 time=69.000 ms
172.16.100.2 icmp_seq=2 time=38.000 ms
172.16.100.2 icmp_seq=3 time=54.000 ms
172.16.100.2 icmp_seq=4 time=121.000 ms
172.16.100.2 icmp_seq=5 time=56.000 ms
接下来开始验证有关OSPF的网络类型的信息!
点到点型(Point-to-Point)
show ip ospf int s0/0查看OSPF的网络类型。如下显示,路由器间的网络类型是点到点型的网络。
Serial0/0 is up, line protocol is up
Internet Address 192.168.1.1/24, Area 1
Process ID 100, Router ID 10.1.1.1, Network Type POINT_TO_POINT, Cost: 64
Transmit Delay is 1 sec, State POINT_TO_POINT,
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:05
Supports Link-local Signaling (LLS)
Index 3/3, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 20.1.1.1
Suppress hello for 0 neighbor(s)
R1
r1#show ip ospf neighbor
20.1.1.1 0 FULL/ - 00:00:31 192.168.1.2 Serial0/0
r2#show ip ospf neighbor
30.1.1.1 0 FULL/ - 00:00:38 192.168.2.2 Serial0/1
10.1.1.1 0 FULL/ - 00:00:31 192.168.1.1 Serial0/0
r3#show ip ospf neighbor
20.1.1.1 0 FULL/ - 00:00:37 192.168.2.1 Serial0/0
40.1.1.1 0 FULL/ - 00:00:32 192.168.3.2 Serial0/1
r4#show ip ospf neighbor
30.1.1.1 0 FULL/ - 00:00:37 192.168.3.1 Serial0/0
R3
r3(config)#int s0/1
r3(config-if)#ip ospf network point-to-multipoint
r4(config)#int s0/0
r4(config-if)#ip ospf network point-to-multipoint
查看OSPF网络类型 ,网络类型已经更改为点到多点型。
Serial0/1 is up, line protocol is up
Internet Address 192.168.3.1/24, Area 2
Process ID 100, Router ID 30.1.1.1, Network Type POINT_TO_MULTIPOINT, Cost: 64
Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
oob-resync timeout 120
Hello due in 00:00:04
Supports Link-local Signaling (LLS)
Index 1/3, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 2
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 40.1.1.1
Suppress hello for 0 neighbor(s)
注意看,此处验证了在点到多点网络中也是不需要选举DR和BDR的。
R3
r3#show ip ospf neighbor
20.1.1.1 0 FULL/ - 00:00:33 192.168.2.1 Serial0/0
40.1.1.1 0 FULL/ - 00:01:42 192.168.3.2 Serial0/1
R4
r4#show ip ospf neighbor
30.1.1.1 0 FULL/ - 00:01:48 192.168.3.1 Serial0/0
r1(config)#int s0/0
r1(config-if)#ip ospf network broadcast
r2(config)#int s0/0
r2(config-if)#ip ospf network broadcast
Serial0/0 is up, line protocol is up
Internet Address 192.168.1.1/24, Area 1
Process ID 100, Router ID 10.1.1.1, Network Type BROADCAST, Cost: 64
Transmit Delay is 1 sec, State BDR, Priority 1
Designated Router (ID) 20.1.1.1, Interface address 192.168.1.2
Backup Designated router (ID) 10.1.1.1, Interface address 192.168.1.1
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:07
Supports Link-local Signaling (LLS)
Index 3/3, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 20.1.1.1 (Designated Router)
Suppress hello for 0 neighbor(s)
R1
20.1.1.1 1 FULL/DR 00:00:31 192.168.1.2 Serial0/0
r2#show ip ospf neighbor
30.1.1.1 0 FULL/ - 00:00:33 192.168.2.2 Serial0/1
10.1.1.1 1 FULL/BDR 00:00:31 192.168.1.1 Serial0/0
r2(config)#int s0/1
r2(config-if)#ip ospf network non-broadcast
r3(config)#int s0/0
r3(config-if)#ip ospf network non-broadcast
命令为:
r2(config-router)#neighbor 192.168.2.2
r3(config-router)#neighbor 192.168.2.1
r2#show ip ospf int s0/1
Serial0/1 is up, line protocol is up
Internet Address 192.168.2.1/24, Area 0
Process ID 100, Router ID 20.1.1.1, Network Type NON_BROADCAST, Cost: 64
Transmit Delay is 1 sec, State BDR, Priority 1
Designated Router (ID) 30.1.1.1, Interface address 192.168.2.2
Backup Designated router (ID) 20.1.1.1, Interface address 192.168.2.1
Flush timer for old DR LSA due in 00:01:53
Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
oob-resync timeout 120
Hello due in 00:00:23
Supports Link-local Signaling (LLS)
Index 1/2, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 4 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 30.1.1.1 (Designated Router)
Suppress hello for 0 neighbor(s)
Neighbor ID Pri State Dead Time Address Interface
30.1.1.1 1 FULL/DR 00:01:46 192.168.2.2 Serial0/1
10.1.1.1 1 FULL/ - 00:00:34 192.168.1.1 Serial0/0
r3#show ip ospf neighbor
20.1.1.1 1 FULL/BDR 00:01:36 192.168.2.1 Serial0/0
40.1.1.1 0 FULL/ - 00:01:53 192.168.3.2 Serial0/1
验证OSPF的LSA类型
如下内容所示,
类型1(Router Link States)的LSA被扩散到区域内的所有路由器!
类型2( Net Link States)的LSA在广播和NBMA网络中生成的!
r1#show ip ospf database
10.1.1.1 10.1.1.1 43 0x80000002 0x00A30C 4
20.1.1.1 20.1.1.1 44 0x80000001 0x00A4EC 2
30.1.1.1 20.1.1.1 31 0x80000001 0x00A320
40.1.1.1 20.1.1.1 30 0x80000001 0x00A3D5
172.16.100.0 20.1.1.1 30 0x80000001 0x00F88A
192.168.2.0 20.1.1.1 41 0x80000001 0x007AFF
192.168.3.0 20.1.1.1 30 0x80000001 0x00F147
R1
r1#show ip ospf database
10.1.1.1 10.1.1.1 8 0x80000004 0x0045CC 3
20.1.1.1 20.1.1.1 9 0x80000003 0x006E7B 1
192.168.1.2 20.1.1.1 9 0x80000001 0x004250
30.1.1.1 20.1.1.1 359 0x80000001 0x00A320
40.1.1.1 20.1.1.1 165 0x80000001 0x00A3D5
172.16.100.0 20.1.1.1 165 0x80000001 0x00F88A
192.168.2.0 20.1.1.1 369 0x80000001 0x007AFF
192.168.3.1 20.1.1.1 179 0x80000001 0x006513
192.168.3.2 20.1.1.1 170 0x80000001 0x00DD59
R2
r2#show ip ospf database
20.1.1.1 20.1.1.1 21 0x80000004 0x007473 1
30.1.1.1 30.1.1.1 22 0x80000003 0x00B0F0 2
192.168.2.2 30.1.1.1 22 0x80000001 0x0091E1
10.1.1.1 20.1.1.1 461 0x80000001 0x00A82F
40.1.1.1 30.1.1.1 622 0x80000003 0x00C2EA
172.16.1.0 20.1.1.1 461 0x80000001 0x00BB6B
172.16.100.0 30.1.1.1 622 0x80000003 0x00189F
192.168.1.0 20.1.1.1 826 0x80000001 0x0085F5
192.168.3.1 30.1.1.1 638 0x80000001 0x008826
192.168.3.2 30.1.1.1 629 0x80000001 0x00016C
10.1.1.1 10.1.1.1 468 0x80000004 0x0045CC 3
20.1.1.1 20.1.1.1 468 0x80000003 0x006E7B 1
192.168.1.2 20.1.1.1 468 0x80000001 0x004250
30.1.1.1 20.1.1.1 19 0x80000001 0x00A320
40.1.1.1 20.1.1.1 20 0x80000001 0x00A3D5
172.16.100.0 20.1.1.1 20 0x80000001 0x00F88A
192.168.2.0 20.1.1.1 830 0x80000001 0x007AFF
192.168.3.1 20.1.1.1 20 0x80000001 0x006513
192.168.3.2 20.1.1.1 20 0x80000001 0x00DD59
末梢区域和完全末梢区域
我们把Area2设置为末梢区域。配置命令如下:
r3(config-router)#area 2 stub
r4(config-router)#area 2 stub
末梢区域不接受AS外部的路由信息。由于我们都处于同意AS内。所以这里就不验证了!
r1(config-router)#area 1 stub no-summary
r2(config-router)#area 1 stub no-summary
完全末梢区域不接受来自AS外部的路由汇总和来自AS中其他区域的汇总路由。
验证:如下所示LSA条目明显减少。这里验证了完全末梢区域的特点。
r1#show ip ospf database
10.1.1.1 10.1.1.1 123 0x80000009 0x00A16D 3
20.1.1.1 20.1.1.1 120 0x80000007 0x008463 1
192.168.1.2 20.1.1.1 120 0x80000004 0x005A37
0.0.0.0 20.1.1.1 125 0x80000001 0x00E73F
我们在R4上添加loop 1 IP地址为 40.1.0.1 255.255.255.0
Loop2 Ip地址为40.1.2.1 255.255.255.0
Loop3 Ip地址为40.1.3.1 255.255.255.0
在R2上查看路由表。我们看到R2的路由表的条目很长,怎样可以减少路由条目呢?这时就用到了路由汇总。
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
C 20.1.1.0 is directly connected, Loopback0
172.16.0.0/24 is subnetted, 2 subnets
O 172.16.1.0 [110/65] via 192.168.1.1, 00:15:08, Serial0/0
O IA 172.16.100.0 [110/129] via 192.168.2.2, 00:15:08, Serial0/1
40.0.0.0/32 is subnetted, 4 subnets
O IA 40.1.0.1 [110/129] via 192.168.2.2, 00:02:01, Serial0/1
O IA 40.1.1.1 [110/129] via 192.168.2.2, 00:15:08, Serial0/1
O IA 40.1.2.1 [110/129] via 192.168.2.2, 00:01:38, Serial0/1
O IA 40.1.3.1 [110/129] via 192.168.2.2, 00:01:18, Serial0/1
10.0.0.0/32 is subnetted, 1 subnets
O 10.1.1.1 [110/65] via 192.168.1.1, 00:15:08, Serial0/0
C 192.168.1.0/24 is directly connected, Serial0/0
C 192.168.2.0/24 is directly connected, Serial0/1
192.168.3.0/32 is subnetted, 2 subnets
O IA 192.168.3.2 [110/128] via 192.168.2.2, 00:15:10, Serial0/1
O IA 192.168.3.1 [110/64] via 192.168.2.2, 00:15:11, Serial0/1
30.0.0.0/32 is subnetted, 1 subnets
O 30.1.1.1 [110/65] via 192.168.2.2, 00:15:26, Serial0/1
r3(config-router)#area 2 range 40.1.0.0 255.255.252.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
C 20.1.1.0 is directly connected, Loopback0
172.16.0.0/24 is subnetted, 2 subnets
O 172.16.1.0 [110/65] via 192.168.1.1, 00:17:36, Serial0/0
O IA 172.16.100.0 [110/129] via 192.168.2.2, 00:17:36, Serial0/1
40.0.0.0/22 is subnetted, 1 subnets
O IA 40.1.0.0 [110/129] via 192.168.2.2, 00:00:30, Serial0/1
10.0.0.0/32 is subnetted, 1 subnets
O 10.1.1.1 [110/65] via 192.168.1.1, 00:17:36, Serial0/0
C 192.168.1.0/24 is directly connected, Serial0/0
C 192.168.2.0/24 is directly connected, Serial0/1
192.168.3.0/32 is subnetted, 2 subnets
O IA 192.168.3.2 [110/128] via 192.168.2.2, 00:17:36, Serial0/1
O IA 192.168.3.1 [110/64] via 192.168.2.2, 00:17:37, Serial0/1
30.0.0.0/32 is subnetted, 1 subnets
O 30.1.1.1 [110/65] via 192.168.2.2, 00:17:53, Serial0/1
本次试验中我们验证了:OSPF的区域类型;OSPF的网络类型;OSPF的LSA类型;末梢区域和完全末梢区域的特性以及OSPF的路由汇总。
怎么样,理论结合试验是不是会让我们对OSPF的理解更透彻呢!