多区域ospf的基本配置

好久没有做过实验了,今天按照按照工大瑞普的实验手册来做ospf的的实验。

拓扑图如图所示

 

实验目的:

1、掌握多区域的OSPF配置方法。

2、区别不同区域的路由。

3、掌握OSPF的路由汇总配置。

4、掌握OSPF的基本配置命令

废话不说,首先按照拓扑图上的要求将路由器的直连接口配置ip地址,配置的时候要注意注意子网掩码与其反掩码,配置完ip地址后,使用ping 命令测试,直连网段是否能够ping通。

然后开始配置ospf

R1配置如下

router ospf 1

network 10.1.1.0 0.0.0.255 area 1

network 10.1.2.0 0.0.0.255 area 1

network 192.168.1.0 0.0.0.3 area 1

R2配置如下

router ospf 1

 lnetwork 192.168.1.0 0.0.0.3 area 1

 network 192.168.1.4 0.0.0.3 area 0

R3 配置如下

router ospf 1

 network 192.168.1.4 0.0.0.3 area 0

 network 192.168.1.8 0.0.0.3 area 2

R4配置如下

 router ospf 1

network 172.16.1.0 0.0.0.255 area 2

 network 172.16.2.0 0.0.0.255 area 2

 network 192.168.1.8 0.0.0.3 area 2   注意反掩码

ospf的基本配置就配置完成了,可以用ping命令 ,在R1  ping 172.16.1.1

输出:Router#ping 172.16.1.1

 

Type escape sequence to abort.

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

!!!!!

R2上查看ospf的邻居表

Router#show ip ospf nei

 

Neighbor ID     Pri   State           Dead Time   Address         Interface

192.168.1.9       0   FULL/  -        00:00:34    192.168.1.6     Serial2/1

10.1.2.1          0   FULL/  -        00:00:29    192.168.1.1     Serial2/0

以上说明 R2已经与另外两台路由器建立了邻居关系。

R1上查看路由表

Router#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

 

     172.16.0.0/32 is subnetted, 2 subnets

O IA    172.16.1.1 [110/193] via 192.168.1.2, 00:11:28, Serial2/0      IA表示从其他区域学习到的路由)

O IA    172.16.2.1 [110/193] via 192.168.1.2, 00:11:25, Serial2/0

     10.0.0.0/24 is subnetted, 2 subnets

C       10.1.2.0 is directly connected, Loopback1

C       10.1.1.0 is directly connected, Loopback0

     192.168.1.0/30 is subnetted, 3 subnets

O IA    192.168.1.8 [110/192] via 192.168.1.2, 00:12:02, Serial2/0

C       192.168.1.0 is directly connected, Serial2/0

O IA    192.168.1.4 [110/128] via 192.168.1.2, 00:13:32, Serial2/0

查看R4的路由表和R4的链路状态数据库

Router#show ip ospf dat

 

            OSPF Router with ID (172.16.2.1) (Process ID 1)

 

                Router Link States (Area 2)

 

Link ID         ADV Router      Age         Seq#       Checksum Link count

172.16.2.1      172.16.2.1      1428        0x80000004 0x00B871 4

192.168.1.9     192.168.1.9     1456        0x80000002 0x00EA2E 2

 

                Summary Net Link States (Area 2)

 

Link ID         ADV Router      Age         Seq#       Checksum

10.1.1.1        192.168.1.9     1040        0x80000001 0x00AB8F

10.1.2.1        192.168.1.9     1040        0x80000001 0x00A099

192.168.1.0     192.168.1.9     1482        0x80000001 0x00766B

192.168.1.4     192.168.1.9     1497        0x80000001 0x00CB52

Router#

Router#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

 

     172.16.0.0/24 is subnetted, 2 subnets

C       172.16.1.0 is directly connected, Loopback0

C       172.16.2.0 is directly connected, Loopback1

     10.0.0.0/32 is subnetted, 2 subnets

O IA    10.1.2.1 [110/193] via 192.168.1.9, 00:17:33, Serial2/0

O IA    10.1.1.1 [110/193] via 192.168.1.9, 00:17:33, Serial2/0

     192.168.1.0/30 is subnetted, 3 subnets

C       192.168.1.8 is directly connected, Serial2/0

O IA    192.168.1.0 [110/192] via 192.168.1.9, 00:23:59, Serial2/0

O IA    192.168.1.4 [110/128] via 192.168.1.9, 00:23:59, Serial2/0

 

可以发现R4路由器学习到area1区域的具体路由,其实,可以通过在R2(ABR)上可以对area1的路由进行汇总,通过汇总可以有效的减少路由表的大小,限制LSA扩散。

 

R2上进行配置

Router(config)router ospf  1

Router(config-router)#area 1 range  10.1.0.0 255.255.0.0

 

然后继续在R4上查看路由表和链路状态数据库。

Router#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

 

     172.16.0.0/24 is subnetted, 2 subnets

C       172.16.1.0 is directly connected, Loopback0

C       172.16.2.0 is directly connected, Loopback1

     10.0.0.0/16 is subnetted, 1 subnets

O IA    10.1.0.0 [110/193] via 192.168.1.9, 00:00:02, Serial2/0

     192.168.1.0/30 is subnetted, 3 subnets

C       192.168.1.8 is directly connected, Serial2/0

O IA    192.168.1.0 [110/192] via 192.168.1.9, 00:24:56, Serial2/0

O IA    192.168.1.4 [110/128] via 192.168.1.9, 00:24:56, Serial2/0

 

Router#show ip ospf dat

 

            OSPF Router with ID (172.16.2.1) (Process ID 1)

 

                Router Link States (Area 2)

 

Link ID         ADV Router      Age         Seq#       Checksum Link count

172.16.2.1      172.16.2.1      1574        0x80000004 0x00B871 4

192.168.1.9     192.168.1.9     1602        0x80000002 0x00EA2E 2

 

                Summary Net Link States (Area 2)

 

Link ID         ADV Router      Age         Seq#       Checksum

10.1.0.0        192.168.1.9     80          0x80000001 0x00C07C

192.168.1.0     192.168.1.9     1628        0x80000001 0x00766B

192.168.1.4     192.168.1.9     1643        0x80000001 0x00CB52

我们会发现进行汇总后,R2配置以后,R4学习到的路由表要比在没有汇总以前要小,限制了lsa的扩散。