实验目的:

1、掌握OSPF的区域汇总。

实验拓扑:

实验步骤:

1、依据图中拓扑配置各设备的IP地址,并保证直连连通性;

在R1上做如下配置:

R1(config)#int f0/0

R1(config-if)#no shutdown

R1(config-if)#ip address 12.1.1.1 255.255.255.0

R1(config-if)#exit

R1(config)#int f1/0

R1(config-if)#no shutdown

R1(config-if)#ip address 13.1.1.1 255.255.255.0

R1(config-if)#exit

R1(config)#int loopback 1

R1(config-if)#ip address 1.1.1.1 255.255.255.255

R1(config-if)#exit

在R2上做如下配置:

R2(config)#int f0/0

R2(config-if)#no shutdown

R2(config-if)#ip address 12.1.1.2 255.255.255.0

R2(config-if)#exit

R2(config)#int f1/0

R2(config-if)#no shutdown

R2(config-if)#ip address 23.1.1.2 255.255.255.0

R2(config-if)#exit

R2(config)#int loopback 1

R2(config-if)#ip address 2.2.2.2 255.255.255.255

R2(config-if)#exit

在R3上做如下配置:

R3(config)#int f0/0

R3(config-if)#no shutdown

R3(config-if)#ip address 13.1.1.3 255.255.255.0

R3(config-if)#exit

R3(config-if)#int f1/0

R3(config-if)#no shutdown

R3(config-if)#ip address 23.1.1.3 255.255.255.0

R3(config-if)#exit

R3(config)#int loopback 1

R3(config-if)#ip address 3.3.3.3 255.255.255.255

R3(config)#int loopback 2

R3(config-if)#ip add 172.16.0.1 255.255.255.0

R3(config-if)#ip add 172.16.1.1 255.255.255.0 secondary 

R3(config-if)#ip add 172.16.2.1 255.255.255.0 secondary

R3(config-if)#ip add 172.16.3.1 255.255.255.0 secondary

R3(config-if)#exit

在其中一台路由器上进行连通性测试:

R1#ping 12.1.1.2


Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 12.1.1.2, timeout is 2 seconds:

.!!!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 20/34/48 ms

R1#ping 13.1.1.3


Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 13.1.1.3, timeout is 2 seconds:

.!!!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 16/31/48 ms

此时说明直连连接没有问题。

2.在每台路由器开始进行OSPF的配置,R1的配置如下:

R1(config)#router ospf 100

R1(config-router)#router-id 1.1.1.1

R1(config-router)#network 12.1.1.0 0.0.0.255 area 0

R1(config-router)#network 13.1.1.0 0.0.0.255 area 0

R1(config-router)#network 1.1.1.1 0.0.0.0 area 1

R1(config-router)#exit

R2的配置如下:

R2(config)#router ospf 100

R2(config-router)#router-id 2.2.2.2

R2(config-router)#network 12.1.1.0 0.0.0.255 area 0

R2(config-router)#network 23.1.1.0 0.0.0.255 area 0

R2(config-router)#network 2.2.2.2 0.0.0.0 area 2

R2(config-router)#exit

R3的配置如下:

R3(config)#router ospf 100

R3(config-router)#router-id 3.3.3.3

R3(config-router)#network 13.1.1.0 0.0.0.255 area 0

R3(config-router)#network 23.1.1.0 0.0.0.255 area 0

R3(config-router)#network 3.3.3.3 0.0.0.0 area 3

R3(config-router)#network 172.16.0.0 0.0.0.255 area 3

R3(config-router)#network 172.16.1.0 0.0.0.255 area 3

R3(config-router)#network 172.16.2.0 0.0.0.255 area 3

R3(config-router)#network 172.16.3.0 0.0.0.255 area 3

R3(config-router)#exit

3、查看OSPF的路由表,在R1上:

R1#show ip route ospf

     2.0.0.0/32 is subnetted, 1 subnets

O IA    2.2.2.2 [110/2] via 12.1.1.2, 00:01:56, FastEthernet0/0

     3.0.0.0/32 is subnetted, 1 subnets

O IA    3.3.3.3 [110/2] via 13.1.1.3, 00:01:56, FastEthernet1/0

     23.0.0.0/24 is subnetted, 1 subnets

O       23.1.1.0 [110/2] via 13.1.1.3, 00:01:56, FastEthernet1/0

                 [110/2] via 12.1.1.2, 00:01:56, FastEthernet0/0

     172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks

O IA    172.16.1.0/24 [110/2] via 13.1.1.3, 00:00:01, FastEthernet1/0

O IA    172.16.0.1/32 [110/2] via 13.1.1.3, 00:00:01, FastEthernet1/0 

O IA    172.16.2.0/24 [110/2] via 13.1.1.3, 00:00:01, FastEthernet1/0

O IA    172.16.3.0/24 [110/2] via 13.1.1.3, 00:00:01, FastEthernet1/0

在R2上:

R2#show ip route ospf

     1.0.0.0/32 is subnetted, 1 subnets

O IA    1.1.1.1 [110/2] via 12.1.1.1, 00:34:34, FastEthernet0/0

     3.0.0.0/32 is subnetted, 1 subnets

O IA    3.3.3.3 [110/2] via 23.1.1.3, 00:34:34, FastEthernet1/0

     172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks

O IA    172.16.1.0/24 [110/2] via 23.1.1.3, 00:00:57, FastEthernet1/0

O IA    172.16.0.1/32 [110/2] via 23.1.1.3, 00:00:57, FastEthernet1/0

O IA    172.16.2.0/24 [110/2] via 23.1.1.3, 00:00:57, FastEthernet1/0

O IA    172.16.3.0/24 [110/2] via 23.1.1.3, 00:00:57, FastEthernet1/0

此时R1和R2从R3学到区域间的4条精细路由,为了减少骨干区域的链路状态数据库,减少路由表体积并降低路由器的压力,可以采用区域间路由汇总技术。

4.在R3上实现区域间路由汇总:

R3(config)#router ospf 100

R3(config-router)# area 3 range 172.16.0.0 255.255.252.0  

R3(config-router)#exit

再次查看R1和R2的路由表:

R1#show ip route ospf

     2.0.0.0/32 is subnetted, 1 subnets

O IA    2.2.2.2 [110/2] via 12.1.1.2, 00:08:19, FastEthernet0/0

     3.0.0.0/32 is subnetted, 1 subnets

O IA    3.3.3.3 [110/2] via 13.1.1.3, 00:08:19, FastEthernet1/0

     23.0.0.0/24 is subnetted, 1 subnets

O       23.1.1.0 [110/2] via 13.1.1.3, 00:08:19, FastEthernet1/0

                 [110/2] via 12.1.1.2, 00:08:19, FastEthernet0/0

     172.16.0.0/22 is subnetted, 1 subnets

O IA    172.16.0.0 [110/2] via 13.1.1.3, 00:00:47, FastEthernet1/0


R2#show ip route ospf

     1.0.0.0/32 is subnetted, 1 subnets

O IA    1.1.1.1 [110/2] via 12.1.1.1, 00:40:16, FastEthernet0/0

     3.0.0.0/32 is subnetted, 1 subnets

O IA    3.3.3.3 [110/2] via 23.1.1.3, 00:40:16, FastEthernet1/0

     172.16.0.0/22 is subnetted, 1 subnets

O IA    172.16.0.0 [110/2] via 23.1.1.3, 00:01:02, FastEthernet1/0

     13.0.0.0/24 is subnetted, 1 subnets

O       13.1.1.0 [110/2] via 23.1.1.3, 00:40:16, FastEthernet1/0

                 [110/2] via 12.1.1.1, 00:40:16, FastEthernet0/0

可以看到原本4条区域间精细路由汇总成一条,说明R3上区域间汇总成功,此实验完成。