配置多区域的OSPF
一、 实验拓扑
二、 设备配置
R1 R1>en R1#conf t
R1(config)#int s 1/0
R1(config-if)#ip add 12.1.1.1 255.255.255.252 R1(config-if)#no sh R1(config-if)#int lo 0
R1(config-if)#ip add 10.0.0.1 255.255.255.0 R1(config-if)#int lo 1
R1(config-if)#ip add 10.0.1.1 255.255.255.0 R1(config-if)#router os 1
实心大白菜:936055160
GIve it everything you've got
R1(config-router)#router os 1
R1(config-router)#net 10.0.0.0 0.0.255.255 a 1 R1(config-router)#net 12.1.1.0 0.0.0.3 a 1 R1(config-router)#
R2 R2>en R2#conf t
R2(config)#int s 1/0
R2(config-if)#ip add 12.1.1.2 255.255.255.252 R2(config-if)#no sh R2(config-if)#int s 1/1
R2(config-if)#ip add 23.1.1.2 255.255.255.252 R2(config-if)#no sh R2(config-if)#router os 1
R2(config-router)#net 12.1.1.0 0.0.0.3 a 1 R2(config-router)#net 23.1.1.0 0.0.0.3 a 0 R2(config-router)# R3 R3>en R3#conf t
R3(config)#int s 1/1
R3(config-if)#ip add 23.1.1.1 255.255.255.252 R3(config-if)#no sh R3(config-if)#int s 1/0
R3(config-if)#ip add 34.1.1.1 255.255.255.252 R3(config-if)#no sh
实心大白菜:936055160
GIve it everything you've got
R3(config-if)#router os 1
R3(config-router)#net 23.1.1.0 0.0.0.3 a 0 R3(config-router)#net 34.1.1.0 0.0.0.3 a 2 R3(config-router)# R4 R4>en R4#conf t
R4(config)#int s 1/0
R4(config-if)#ip add 34.1.1.2 255.255.255.252 R4(config-if)#no sh R4(config-if)#int lo 0
R4(config-if)#ip add 172.16.0.1 255.255.255.0 R4(config-if)#int lo 1
R4(config-if)#ip add 172.16.1.1 255.255.255.0 R4(config-if)#router os 1
R4(config-router)#net 172.16.0.0 0.0.3.255 a 2 R4(config-router)#net 34.1.1.0 0.0.0.3 a 2 R4(config-router)#
三、 验证
3.1 查看OSPF邻居表建立情况
在R2上查看
R2(config-router)#do show ip os nei
Neighbor ID Pri State Dead Time 实心大白菜:936055160
Address Interface
GIve it everything you've got
34.1.1.1 0 FULL/ - 00:00:30 23.1.1.1 Serial1/1 10.0.1.1 0 FULL/ - 00:00:38 12.1.1.1 Serial1/0 R2(config-router)#
在R3上查看
R3(config-router)#do show ip os nei
Neighbor ID Pri State Dead Time Address 23.1.1.2 0 FULL/ - 00:00:36 23.1.1.2 172.16.1.1 0 FULL/ - 00:00:34 34.1.1.2 R3(config-router)#
3.2 观察路由学习情况
查看R1路由表
R1(config-router)#do 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
34.0.0.0/30 is subnetted, 1 subnets
实心大白菜:936055160
Interface Serial1/1 Serial1/0 GIve it everything you've got
O IA 34.1.1.0 [110/192] via 12.1.1.2, 00:05:54, Serial1/0 23.0.0.0/30 is subnetted, 1 subnets
O IA 23.1.1.0 [110/128] via 12.1.1.2, 00:07:24, Serial1/0 172.16.0.0/32 is subnetted, 2 subnets
O IA 172.16.1.1 [110/193] via 12.1.1.2, 00:05:16, Serial1/0
O IA 172.16.0.1 [110/193] via 12.1.1.2, 00:05:16, Serial1/0 //OSPF区域间路由IA=>OSPF inter area
10.0.0.0/24 is subnetted, 2 subnets
C 10.0.0.0 is directly connected, Loopback0 C 10.0.1.0 is directly connected, Loopback1 12.0.0.0/30 is subnetted, 1 subnets C 12.1.1.0 is directly connected, Serial1/0
可以使用关键字 刷选出OSPF路由 R1(config-router)#do show ip route os 34.0.0.0/30 is subnetted, 1 subnets
O IA 34.1.1.0 [110/192] via 12.1.1.2, 00:06:10, Serial1/0 23.0.0.0/30 is subnetted, 1 subnets
O IA 23.1.1.0 [110/128] via 12.1.1.2, 00:07:40, Serial1/0 172.16.0.0/32 is subnetted, 2 subnets
O IA 172.16.1.1 [110/193] via 12.1.1.2, 00:05:32, Serial1/0 O IA 172.16.0.1 [110/193] via 12.1.1.2, 00:05:32, Serial1/0 R1(config-router)#
备注:OSPF cost值计算公式:Cost= 10^8 / Bandwidth
实心大白菜:936055160
GIve it everything you've got
3.3 查看OSPF链路状态数据库
查看R1的链路状态数据库 R1(config-router)#do show ip ospf dat
OSPF Router with ID (10.0.1.1) (Process ID 1)
Router Link States (Area 1) //类型1LSA,路由器LSA,描述区域内的路由器接口的链路状态及链路开销
Link ID ADV Router Age Seq# Checksum Link count 10.0.1.1 10.0.1.1 1460 0x80000003 0x0079A2 4 23.1.1.2 23.1.1.2 1389 0x80000004 0x00D36F 2
Summary Net Link States (Area 1) //类型3LSA,描述区域间路由
Link ID ADV Router Age Seq# Checksum 23.1.1.0 23.1.1.2 1385 0x80000001 0x00CBFF 34.1.1.0 23.1.1.2 1294 0x80000001 0x00BEC1 172.16.0.1 23.1.1.2 1256 0x80000001 0x001EC4
172.16.1.1 23.1.1.2 1256 0x80000001 0x0013CE //关于areas 2 的两条类型3的LSA
R1(config-router)#
备注:R1学到了R4的两条明细路由,可以使用路由汇总限制明细路由的传播,减少路由表的大小。
实心大白菜:936055160
GIve it everything you've got
3.4 配置OSPF汇总
在R3上配置针对R4环回口路由的汇总 (OSPF只在ABR上进行汇总) R3(config)#router os 1
R3(config-router)#area 2 rang 172.16.0.0 255.255.252.0
再次查看R1的路由表
R1(config-router)#do show ip route os 34.0.0.0/30 is subnetted, 1 subnets
O IA 34.1.1.0 [110/192] via 12.1.1.2, 00:28:28, Serial1/0 23.0.0.0/30 is subnetted, 1 subnets
O IA 23.1.1.0 [110/128] via 12.1.1.2, 00:29:57, Serial1/0 172.16.0.0/22 is subnetted, 1 subnets
O IA 172.16.0.0 [110/193] via 12.1.1.2, 00:00:33, Serial1/0 //汇总过后的路由条目 R1(config-router)#
查看R1的链路状态数据库 R1(config-router)#do show ip os da
OSPF Router with ID (10.0.1.1) (Process ID 1)
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count 10.0.1.1 10.0.1.1 48 0x80000004 0x0077A3 4 23.1.1.2 23.1.1.2 1863 0x80000004 0x00D36F 2
实心大白菜:936055160
GIve it everything you've got
Summary Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum 23.1.1.0 23.1.1.2 1858 0x80000001 0x00CBFF 34.1.1.0 23.1.1.2 1768 0x80000001 0x00BEC1
172.16.0.0 23.1.1.2 94 0x80000001 0x0019CD // : 对于area 2的区域仅有一条类型3 的LSA。
R1(config-router)#
实心大白菜:936055160
因篇幅问题不能全部显示,请点此查看更多更全内容