实验目的:1.掌握多区域ospf配置方法
2.区别不同区域的路由
3.掌握ospf的路由汇总配置
4.掌握ospf的基本配置命令
实验拓扑:
步骤1:接口ip配置
R1(config)#interface f0/0
R1(config-if)#ip address 12.12.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#interface loopback 0
R1(config-if)#ip address 10.1.1.1 255.255.255.0
R1(config)#interface loopback 1
R1(config-if)#ip address 10.1.2.2 255.255.255.0
R2(config)#interface f0/0
R2(config-if)#ip address 12.12.12.2 255.255.255.0
R2(config-if)#no shutdown
R2(config)#interface f0/1
R2(config-if)#ip address 23.23.23.2 255.255.255.0
R2(config-if)#no shutdown
R3(config)#interface f0/1
R3(config-if)#ip address 23.23.23.3 255.255.255.0
R3(config-if)#no shutdown
R3(config)#interface f0/0
R3(config-if)#ip address 34.34.34.3 255.255.255.0
R3(config-if)#no shutdown
R4(config)#interface f0/0
R4(config-if)#ip address 34.34.34.4 255.255.255.0
R4(config-if)#no shutdown
R4(config)#interface loopback 0
R4(config-if)#ip address 40.1.1.1 255.255.255.0
R4(config)#interface loopback 1
R4(config-if)#ip address 40.1.2.1 255.255.255.0
步骤2:ospf路由宣告
R1(config)#router ospf 1
R1(config-router)#network 12.12.12.0 0.0.0.255 area 1
R1(config-router)#network 10.1.1.1 0.0.0.0 area 1
R1(config-router)#network 10.1.2.2 0.0.0.0 area 1
R2(config)#router ospf 1
R2(config-router)#network 12.12.12.0 0.0.0.255 area 1
R2(config-router)#network 23.23.23.0 0.0.0.255 area 0
R3(config)#router ospf 1
R3(config-router)#network 23.23.23.0 0.0.0.255 area 0
R3(config-router)#network 34.34.34.0 0.0.0.255 area 2
R4(config)#router ospf 1
R4(config-router)#network 34.34.34.0 0.0.0.255 area 2
R4(config-router)#network 40.1.1.1 0.0.0.0 area 2
R4(config-router)#network 40.1.2.1 0.0.0.0 area 2
查看网络联通性
R4#ping 40.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 40.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
在任一路由器上查看ospf邻居表
R2#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
34.34.34.3 1 FULL/BDR 00:00:31 23.23.23.3 FastEthernet0/1
10.1.2.2 1 FULL/DR 00:00:38 12.12.12.1 FastEthernet0/0
查看R1路由表
R1#show ip route
Gateway of last resort is not set
34.0.0.0/24 is subnetted, 1 subnets
O IA 34.34.34.0 [110/3] via 12.12.12.2, 00:06:07, FastEthernet0/0
//其它区域路由会使用IA作为前缀。IA short fot OSPF inter area
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.23.23.0 [110/2] via 12.12.12.2, 00:06:54, FastEthernet0/0
40.0.0.0/32 is subnetted, 2 subnets
O IA 40.1.1.1 [110/4] via 12.12.12.2, 00:05:22, FastEthernet0/0
O IA 40.1.2.1 [110/4] via 12.12.12.2, 00:05:12, FastEthernet0/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
12.0.0.0/24 is subnetted, 1 subnets
C 12.12.12.0 is directly connected, FastEthernet0/0
查看R1的ospf链路状态数据库
R1#show ip ospf database
OSPF Router with ID (10.1.2.2) (Process ID 1)
Router Link States (Area 1) //区域1的类型1 LSA
Link ID ADV Router Age Seq# Checksum Link count
10.1.2.2 10.1.2.2 930 0x80000004 0x003851 3
23.23.23.2 23.23.23.2 921 0x80000003 0x005AFB 1
Net Link States (Area 1) //类型3的LSA,描述区域间的路由
Link ID ADV Router Age Seq# Checksum
12.12.12.1 10.1.2.2 930 0x80000001 0x003778
Summary Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
23.23.23.0 23.23.23.2 919 0x80000001 0x001E91
34.34.34.0 23.23.23.2 869 0x80000001 0x009AF2
40.1.1.1 23.23.23.2 824 0x80000001 0x004681
40.1.2.1 23.23.23.2 814 0x80000001 0x003B8B
查看R4的路由表和ospf链路状态数据库
R4#show ip route
Gateway of last resort is not set
34.0.0.0/24 is subnetted, 1 subnets
C 34.34.34.0 is directly connected, FastEthernet0/0
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.23.23.0 [110/2] via 34.34.34.3, 00:15:36, FastEthernet0/0
40.0.0.0/24 is subnetted, 2 subnets
C 40.1.1.0 is directly connected, Loopback0
C 40.1.2.0 is directly connected, Loopback1
10.0.0.0/32 is subnetted, 2 subnets
O IA 10.1.2.2 [110/4] via 34.34.34.3, 00:15:36, FastEthernet0/0
O IA 10.1.1.1 [110/4] via 34.34.34.3, 00:15:37, FastEthernet0/0
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.12.12.0 [110/3] via 34.34.34.3, 00:15:37, FastEthernet0/0
R4#show ip ospf database
OSPF Router with ID (40.1.2.1) (Process ID 1)
Router Link States (Area 2)
Link ID ADV Router Age Seq# Checksum Link count
34.34.34.3 34.34.34.3 1026 0x80000002 0x000586 1
40.1.2.1 40.1.2.1 1004 0x80000004 0x000783 3
Net Link States (Area 2)
Link ID ADV Router Age Seq# Checksum
34.34.34.3 34.34.34.3 1026 0x80000001 0x00AE23
Summary Net Link States (Area 2)
Link ID ADV Router Age Seq# Checksum
10.1.1.1 34.34.34.3 1061 0x80000001 0x00BE05
10.1.2.2 34.34.34.3 1061 0x80000001 0x00A918
12.12.12.0 34.34.34.3 1061 0x80000001 0x00A607
23.23.23.0 34.34.34.3 1066 0x80000001 0x000F7E
可以发现R4路由器学习到area1区域的具体路由。
其实,可以通过在R2(ABR)上对area1的路由进行汇总,通过汇总可以有效的减少路由表大小,限制LSA扩散。
步骤3:配置R2的区域汇总
R2(config)#router ospf 1
R2(config-router)#area 1 range 10.1.0.0 255.255.0.0
再次查看R4路由表和链路状态数据库
R4#show ip route
Gateway of last resort is not set
34.0.0.0/24 is subnetted, 1 subnets
C 34.34.34.0 is directly connected, FastEthernet0/0
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.23.23.0 [110/2] via 34.34.34.3, 00:00:01, FastEthernet0/0
40.0.0.0/24 is subnetted, 2 subnets
C 40.1.1.0 is directly connected, Loopback0
C 40.1.2.0 is directly connected, Loopback1
10.0.0.0/16 is subnetted, 1 subnets
O IA 10.1.0.0 [110/4] via 34.34.34.3, 00:00:01, FastEthernet0/0
//area 1的路由已经成功地被汇总。如果area 1存在多条路由的话,这样做是很有实际意义的
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.12.12.0 [110/3] via 34.34.34.3, 00:00:03, FastEthernet0/0
R4#show ip ospf database
OSPF Router with ID (40.1.2.1) (Process ID 1)
Router Link States (Area 2)
Link ID ADV Router Age Seq# Checksum Link count
34.34.34.3 34.34.34.3 1750 0x80000002 0x000586 1
40.1.2.1 40.1.2.1 1729 0x80000004 0x000783 3
Net Link States (Area 2)
Link ID ADV Router Age Seq# Checksum
34.34.34.3 34.34.34.3 1750 0x80000001 0x00AE23
Summary Net Link States (Area 2)
Link ID ADV Router Age Seq# Checksum
10.1.0.0 34.34.34.3 158 0x80000001 0x00D3F1
//对于area 1区域仅有一条类型3的LSA
12.12.12.0 34.34.34.3 1786 0x80000001 0x00A607
23.23.23.0 34.34.34.3 1791 0x80000001 0x000F7E