一、实验目的:
1.学习多区域OSPF路由的配置 2.分析OSPF与链路接口的关系
3.分析OSPF的链路状态数据库表、邻居表、路由表 4.学习ABR和ASBR路由器上进行路由汇总 5.OSPF默认路由的注入 二、实验拓朴:
三、基本配置命令 R1
enable
configure terminal noip domain-lookup hostname R1
interface serial0/0/0
ip address 172.16.12.1 255.255.255.0 no shutdown
interfacefastethernet 0/0
ip address 172.16.13.1 255.255.255.0 no shutdown
interface loopback 1
ip address 172.16.21.1 255.255.255.0 end
showip interface brief
enable
configure terminal routerospf 100
network 172.16.12.0 0.0.0.255 area 1 network 172.16.13.0 0.0.0.255 area 0 network 172.16.21.0 0.0.0.255 area 0 end
showip route
========================================= R2
enable
configure terminal noip domain-lookup hostname R2
interface serial0/0/0
ip address 172.16.12.2 255.255.255.0 no shutdown
interface loopback 1
ip address 172.16.0.1 255.255.255.0 interface loopback 2
ip address 172.16.1.1 255.255.255.0 interface loopback 3
ip address 172.16.2.1 255.255.255.0 interface loopback 4
ip address 172.16.3.1 255.255.255.0 end
showip interface brief
enable
configure terminal
routerospf 100
network 172.16.12.0 0.0.0.255 area 1 network 172.16.0.0 0.0.0.255 area 1 network 172.16.1.0 0.0.0.255 area 1 network 172.16.2.0 0.0.0.255 area 1 network 172.16.3.0 0.0.0.255 area 1 end
showip route
=========================================
RSW1
enable
configure terminal noip domain-lookup hostname RSW1 ip routing
interfacefastethernet 0/1 no switchport
ip address 172.16.13.3 255.255.255.0 no shutdown
interfacefastethernet 0/2 noswitchport
ip address 172.16.34.3 255.255.255.0 no shutdown end
showip interface brief
enable
configure terminal routerospf 100
network 172.16.13.0 0.0.0.255 area 0 network 172.16.34.0 0.0.0.255 area 2 end
showip route
=========================================
RSW2
enable
configure terminal
noip domain-lookup hostname RSW2 ip routing
interfacefastethernet 0/2 no switchport
ip address 172.16.34.4 255.255.255.0 no shutdown
interfacefastethernet 0/1 noswitchport
ip address 172.16.45.4 255.255.255.0 no shutdown
interface loopback 1
ip address 172.16.4.1 255.255.255.0 interface loopback 2
ip address 172.16.5.1 255.255.255.0 interface loopback 3
ip address 172.16.6.1 255.255.255.0 interface loopback 4
ip address 172.16.7.1 255.255.255.0 end
showip interface brief
enable
configure terminal routerospf 100
network 172.16.34.0 0.0.0.255 area 2 network 172.16.4.0 0.0.0.255 area 2 network 172.16.5.0 0.0.0.255 area 2 network 172.16.6.0 0.0.0.255 area 2 network 172.16.7.0 0.0.0.255 area 2 ip route 0.0.0.0 0.0.0.0 172.16.45.5 end
showip route
========================================= RSW3
enable
configure terminal noip domain-lookup hostname RSW3 ip routing
interfacefastethernet 0/1 no switchport
ip address 172.16.45.5 255.255.255.0 no shutdown
interface loopback 1
ip address 172.16.8.1 255.255.255.0 interface loopback 2
ip address 172.16.9.1 255.255.255.0 interface loopback 3
ip address 172.16.10.1 255.255.255.0 interface loopback 4
ip address 172.16.11.1 255.255.255.0 end
showip interface brief
enable
configure terminal
ip route 0.0.0.0 0.0.0.0 172.16.45.4 end
showip route
=========================================
四、调试与分析 1、show ip route R1#show ip route
172.16.0.0/16 is variably subnetted, 12 subnets, 2 masks
O 172.16.0.1/32 [110/65] via 172.16.12.2, 00:14:10, Serial0/0/0 O 172.16.1.1/32 [110/65] via 172.16.12.2, 00:14:10, Serial0/0/0 O 172.16.2.1/32 [110/65] via 172.16.12.2, 00:14:10, Serial0/0/0 O 172.16.3.1/32 [110/65] via 172.16.12.2, 00:14:10, Serial0/0/0 //以上为区域内路由
O IA 172.16.4.1/32 [110/3] via 172.16.13.3, 00:11:34, FastEthernet0/0 O IA 172.16.5.1/32 [110/3] via 172.16.13.3, 00:11:34, FastEthernet0/0 O IA 172.16.6.1/32 [110/3] via 172.16.13.3, 00:11:34, FastEthernet0/0 O IA 172.16.7.1/32 [110/3] via 172.16.13.3, 00:11:34, FastEthernet0/0 //以上为区域间的路由
C 172.16.12.0/24 is directly connected, Serial0/0/0 C 172.16.13.0/24 is directly connected, FastEthernet0/0 C 172.16.21.0/24 is directly connected, Loopback1
O IA 172.16.34.0/24 [110/2] via 172.16.13.3, 00:12:45, FastEthernet0/0
2、show ip route ospf 查看路由表
R1#show ip route ospf
172.16.0.0/16 is variably subnetted, 12 subnets, 2 masks
O 172.16.0.1 [110/65] via 172.16.12.2, 00:27:10, Serial0/0/0 O 172.16.1.1 [110/65] via 172.16.12.2, 00:27:10, Serial0/0/0 O 172.16.2.1 [110/65] via 172.16.12.2, 00:27:10, Serial0/0/0 O 172.16.3.1 [110/65] via 172.16.12.2, 00:27:10, Serial0/0/0
O IA 172.16.4.1 [110/3] via 172.16.13.3, 00:24:34, FastEthernet0/0 O IA 172.16.5.1 [110/3] via 172.16.13.3, 00:24:34, FastEthernet0/0 O IA 172.16.6.1 [110/3] via 172.16.13.3, 00:24:34, FastEthernet0/0 O IA 172.16.7.1 [110/3] via 172.16.13.3, 00:24:34, FastEthernet0/0 O IA 172.16.34.0 [110/2] via 172.16.13.3, 00:25:45, FastEthernet0/0
3、show ipospf
本命令是显示路由器运行OSPF协议情况,如路由器上的区域信息、路由器的ID、OSPF进程ID R1#show ipospf
Routing Process \"ospf 100\" with ID 172.16.21.1 Supports only single TOS(TOS0) routes Supports opaque LSA
It is an area border router
SPF schedule delay 5 secs, Hold time between two SPFs 10 secs Minimum LSA interval 5 secs. Minimum LSA arrival 1 secs
//最低LSA间隔5秒。最低LSA到来1秒
Number of external LSA 0. Checksum Sum 0x000000 Number of opaque AS LSA 0. Checksum Sum 0x000000 Number of DCbitless external and opaque AS LSA 0 Number of DoNotAge external and opaque AS LSA 0
Number of areas in this router is 2. 2 normal 0 stub 0 nssa External flood list length 0 Area 1
Number of interfaces in this area is 1 Area has no authentication SPF algorithm executed 6 times Area ranges are
Number of LSA 9. Checksum Sum 0x06186f
Number of opaque link LSA 0. Checksum Sum 0x000000 Number of DCbitless LSA 0 Number of indication LSA 0 Number of DoNotAge LSA 0 Flood list length 0 Area BACKBONE(0)
Number of interfaces in this area is 2
Area has no authentication SPF algorithm executed 5 times Area ranges are
Number of LSA 13. Checksum Sum 0x04a575
Number of opaque link LSA 0. Checksum Sum 0x000000 Number of DCbitless LSA 0 Number of indication LSA 0 Number of DoNotAge LSA 0 Flood list length 0
4、show ipospf interface 查看运行OSPF接口信息
R1#show ipospf inter s0/0/0
Serial0/0/0 is up, line protocol is up Internet address is 172.16.12.1/24, Area 1 Process ID 100, Router ID 172.16.21.1, Network Type POINT-TO-POINT, Cost: 64
Transmit Delay is 1 sec, State POINT-TO-POINT, Priority 0 No designated router on this network
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 Hello due in 00:00:08
Index 1/1, 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 172.16.3.1 Suppress hello for 0 neighbor(s)
5、show ipospf neighbor
查看OSPF邻居的基本信息 R1#show ipospf neighbor
Neighbor ID Pri State Dead Time Address Interface 172.16.3.1 0 FULL/ - 00:00:35 172.16.12.2 Serial0/0/0
172.16.34.3 1 FULL/BDR 00:00:38 172.16.13.3 FastEthernet0/0
RSW1#show ipospf neighbor
Neighbor ID Pri State Dead Time Address Interface
172.16.21.1 1 FULL/DR 00:00:37 172.16.13.1 FastEthernet0/1 172.16.7.1 1 FULL/BDR 00:00:32 172.16.34.4 FastEthernet0/2
6、show ipospf database 查看LSA(链路状态通告) R1#show ipospf database
OSPF Router with ID (172.16.21.1) (Process ID 100)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count 172.16.21.1 172.16.21.1 719 0x80000004 0x0052df 2 172.16.34.3 172.16.34.3 719 0x80000004 0x00f302 1
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
172.16.13.1 172.16.21.1 719 0x80000002 0x0085e1
Summary Net Link States (Area 0) Link ID ADV Router Age Seq# Checksum
172.16.12.0 172.16.21.1 849 0x80000006 0x00cbb2 172.16.0.1 172.16.21.1 789 0x80000007 0x004e39 172.16.1.1 172.16.21.1 789 0x80000008 0x004144 172.16.2.1 172.16.21.1 789 0x80000009 0x00344f 172.16.3.1 172.16.21.1 789 0x8000000a 0x00275a 172.16.34.0 172.16.34.3 714 0x80000006 0x00f89f 172.16.4.1 172.16.34.3 639 0x80000007 0x004271 172.16.5.1 172.16.34.3 639 0x80000008 0x00357c 172.16.6.1 172.16.34.3 639 0x80000009 0x002887 172.16.7.1 172.16.34.3 639 0x8000000a 0x001b92
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count 172.16.21.1 172.16.21.1 796 0x80000004 0x00e3e5 2 172.16.3.1 172.16.3.1 795 0x80000007 0x00e9ad 6
Summary Net Link States (Area 1) Link ID ADV Router Age Seq# Checksum
172.16.13.0 172.16.21.1 846 0x80000008 0x004476 172.16.21.1 172.16.21.1 846 0x80000009 0x00dfd0 172.16.34.0 172.16.21.1 706 0x8000000a 0x006240 172.16.4.1 172.16.21.1 636 0x8000000b 0x00ab12 172.16.5.1 172.16.21.1 636 0x8000000c 0x009e1d 172.16.6.1 172.16.21.1 636 0x8000000d 0x009128 172.16.7.1 172.16.21.1 636 0x8000000e 0x008433 7、show ip route ospf
查看路表(前面出现了)
OSPF路由协议特别关注接口的链路状态。
五、OSPF路由汇总 汇总的优点:
1. 减少路由表的尺寸
2. 使路由拓朴变化在局部区域内
3. 降低LSA3和LSA5的泛洪,释放CPU等资源 (LSA:link-state advertisement)
OSPF的路由汇总只能在ABR(区域边界路由器Area Border Router)和ASBR(自治系统边界路由器Autonomous System Boundary Router)上进行,在区域内路由器上做不会起任何作用。
(一)、在区域边界路由器上做汇总的命令是:
在路由模式下,执行 #Area areaIDrange address mask
例如在R1路由器做汇总之前看一下R1和RSW1的路由表: R1#show ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 12 subnets, 2 masks
O 172.16.0.1/32 [110/65] via 172.16.12.2, 00:58:47, Serial0/0/0 O 172.16.1.1/32 [110/65] via 172.16.12.2, 00:58:47, Serial0/0/0 O 172.16.2.1/32 [110/65] via 172.16.12.2, 00:58:47, Serial0/0/0 O 172.16.3.1/32 [110/65] via 172.16.12.2, 00:58:47, Serial0/0/0
O IA 172.16.4.1/32 [110/3] via 172.16.13.3, 00:56:12, FastEthernet0/0 O IA 172.16.5.1/32 [110/3] via 172.16.13.3, 00:56:12, FastEthernet0/0 O IA 172.16.6.1/32 [110/3] via 172.16.13.3, 00:56:12, FastEthernet0/0 O IA 172.16.7.1/32 [110/3] via 172.16.13.3, 00:56:12, FastEthernet0/0 C 172.16.12.0/24 is directly connected, Serial0/0/0 C 172.16.13.0/24 is directly connected, FastEthernet0/0 C 172.16.21.0/24 is directly connected, Loopback1
O IA 172.16.34.0/24 [110/2] via 172.16.13.3, 00:57:22, FastEthernet0/0 共12行
RSW1#show ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 12 subnets, 2 masks
O IA 172.16.0.1/32 [110/66] via 172.16.13.1, 00:57:49, FastEthernet0/1 O IA 172.16.1.1/32 [110/66] via 172.16.13.1, 00:57:49, FastEthernet0/1 O IA 172.16.2.1/32 [110/66] via 172.16.13.1, 00:57:49, FastEthernet0/1
O IA 172.16.3.1/32 [110/66] via 172.16.13.1, 00:57:49, FastEthernet0/1 O 172.16.4.1/32 [110/2] via 172.16.34.4, 00:56:33, FastEthernet0/2 O 172.16.5.1/32 [110/2] via 172.16.34.4, 00:56:33, FastEthernet0/2 O 172.16.6.1/32 [110/2] via 172.16.34.4, 00:56:33, FastEthernet0/2 O 172.16.7.1/32 [110/2] via 172.16.34.4, 00:56:33, FastEthernet0/2 O IA 172.16.12.0/24 [110/65] via 172.16.13.1, 00:57:49, FastEthernet0/1 C 172.16.13.0/24 is directly connected, FastEthernet0/1
O 172.16.21.1/32 [110/2] via 172.16.13.1, 00:57:49, FastEthernet0/1 C 172.16.34.0/24 is directly connected, FastEthernet0/2 共12行
在R1进行汇总
R1(config)#router ospf 100
R1(config-router)#area 1 range 172.16.0.0 255.255.252.0
在RSW1查看结果: RSW1#show ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 9 subnets, 3 masks
O IA 172.16.0.0/22 [110/66] via 172.16.13.1, 00:00:07, FastEthernet0/1 O 172.16.4.1/32 [110/2] via 172.16.34.4, 01:04:30, FastEthernet0/2 O 172.16.5.1/32 [110/2] via 172.16.34.4, 01:04:30, FastEthernet0/2 O 172.16.6.1/32 [110/2] via 172.16.34.4, 01:04:30, FastEthernet0/2 O 172.16.7.1/32 [110/2] via 172.16.34.4, 01:04:30, FastEthernet0/2 O IA 172.16.12.0/24 [110/65] via 172.16.13.1, 01:05:45, FastEthernet0/1 C 172.16.13.0/24 is directly connected, FastEthernet0/1
O 172.16.21.1/32 [110/2] via 172.16.13.1, 01:05:45, FastEthernet0/1 C 172.16.34.0/24 is directly connected, FastEthernet0/2 还剩9条
在RSW1进行汇总:
RSW1(config)#router ospf 100
RSW1(config-router)#area 2 range 172.16.4.0 255.255.252.0
在R1上查看结果: R1#sh ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 9 subnets, 3 masks
O 172.16.0.1/32 [110/65] via 172.16.12.2, 01:12:30, Serial0/0/0 O 172.16.1.1/32 [110/65] via 172.16.12.2, 01:12:30, Serial0/0/0 O 172.16.2.1/32 [110/65] via 172.16.12.2, 01:12:30, Serial0/0/0
O 172.16.3.1/32 [110/65] via 172.16.12.2, 01:12:30, Serial0/0/0
O IA 172.16.4.0/22 [110/3] via 172.16.13.3, 00:00:46, FastEthernet0/0 C 172.16.12.0/24 is directly connected, Serial0/0/0 C 172.16.13.0/24 is directly connected, FastEthernet0/0 C 172.16.21.0/24 is directly connected, Loopback1
O IA 172.16.34.0/24 [110/2] via 172.16.13.3, 01:11:05, FastEthernet0/0 还剩9条
(二)、在自治系统边界路由器(ASBR)上做汇总的命令是:
在路由模式下,执行 #summary-address address mask 我们在RSW2上做,先做一下准备:
去掉RSW2上的静态路由和RSW3上的静态路由 在RSW2上
RSW2>enable
RSW2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z. RSW2(config)#no ip route 0.0.0.0 0.0.0.0 172.16.45.5
在RSW3上
RSW3>enable
RSW3#configure terminal
Enter configuration commands, one per line. End with CNTL/Z. RSW3(config)#no ip route 0.0.0.0 0.0.0.0 172.16.45.4 好了,RSW2和RSW3上的默认路由去掉了
再在RSW2和RSW3上分别做RIP路由 RSW2(config)#router rip
RSW2(config-router)#version 2
RSW2(config-router)#no auto-summary
RSW2(config-router)#network 172.16.45.0 RSW2(config-router)#network 172.16.0.0
RSW3(config)#router rip
RSW3(config-router)#version 2
RSW3(config-router)#no auto-summary
RSW3(config-router)#network 172.16.45.0 RSW3(config-router)#network 172.16.0.0
RSW2(config)#
RSW2(config)#router ospf 100
RSW2(config-router)#summary-address 172.16.8.0 255.255.252.0
让area 0、1和2区域全部学到RIP路由,需要向OSPF路由区域中注入RIP路由,方法是:
在OSPF路由模式下,执行:redistribute rip metric number subnets 在RSW2上去做: RSW2>enable
RSW2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z. RSW2(config)#router ospf 100
RSW2(config-router)#redistribute rip metri
RSW2(config-router)#redistribute rip metric 15 subnets
六、向OSPF区域中注入默认路由
将上面做的RIP路由再去掉(此处略去操作步骤) 在RSW2和RSW3上分别做缺省路由:no router rip 做默认路由:
RSW2(config)#ip route 0.0.0.0 0.0.0.0 172.16.45.2
RSW3(config)#ip route 0.0.0.0 0.0.0.0 172.16.45.4
在RSW2上注入默认路由:
RSW2>enable
RSW2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z. RSW2(config)#router ospf 100
RSW2(config-router)#default-information or
RSW2(config-router)#default-information originate
因篇幅问题不能全部显示,请点此查看更多更全内容