2.9 OSPF基本配置
实验目的:
1、掌握OSPF的单区域配置。
2、掌握OSPF的邻居表、数据库、路由表。
3、理解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-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[PL1]
R1(config-router)#router-id 1.1.1.1[PL2]
R1(config-router)#network 12.1.1.0 0.0.0.255 area 0[PL3]
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 0
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 0
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 0
R3(config-router)#exit
3、查看OSPF的邻居表、数据库及路由表,例如在R1上查看邻居表:
R1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 1 FULL/DR 00:00:39 13.1.1.3 FastEthernet1/0
2.2.2.2 1 FULL/DR 00:00:31 12.1.1.2 FastEthernet0/0
其中Neighbor ID表示邻居的RID,Pri表示邻居的接口优先级,State表示邻居与本地的状态以及邻居的DR/BDR/Drother角色;从这里可以看出,R1与R2和R3已经建立邻接关系,并且R2和R3都是DR。
在R1上查看OSPF链路状态数据库:
R1#show ip ospf database
OSPF Router with ID (1.1.1.1) (Process ID 100)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 277 0x8000000B 0x00625B 3
2.2.2.2 2.2.2.2 243 0x80000006 0x00544A 3
3.3.3.3 3.3.3.3 244 0x80000003 0x00B2DE 3
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
12.1.1.1 1.1.1.1 277 0x80000003 0x0046D2
13.1.1.1 1.1.1.1 282 0x80000003 0x006BA8
23.1.1.3 3.3.3.3 243 0x80000001 0x00AE4F
OSPF的数据库放置着整个OSPF区域的“地图”信息,即LSA信息,在后续PingingLab高级路由部分有详细介绍。
在R1上查看OSPF路由表:
R1#show ip route ospf
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/2] via 12.1.1.2, 00:07:31, FastEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/2] via 13.1.1.3, 00:07:31, FastEthernet1/0
23.0.0.0/24 is subnetted, 1 subnets
O 23.1.1.0 [110/2] via 13.1.1.3, 00:07:31, FastEthernet1/0
[110/2] via 12.1.1.2, 00:07:31, FastEthernet0/0
此时可以看到,R1从R2和R3上学到其环回网段,进行连通性测试,如下:
R1#ping 2.2.2.2 source 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/26/40 ms
R1#ping 3.3.3.3 source 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/24/44 ms
同样的方法在R2和R3上进行测试,可以发现,通过运行OSPF协议,全网连通,此实验完成。
[PL3]Network + 网段+ 反掩码+ 区域号,区域号是OSPF用于实现区域划分的工具,通过划分区域,可以使网络从扁平化走向层次化,除了方便管理,还可以减少路由动荡,减轻路由器压力;区域号范围从0到4294967295,区域分为骨干区域和常规区域,一般区域0表示骨干区域,用于连接其他常规区域并实现流量中转。
==========================================
PingingLab·高品质IT教育提供商
CCIE 实验室·IT项目实战·高端人才定制
深圳拼客信息科技有限公司·广州大学城外环西路站
新浪微博:@拼客科技PingingLab @PingingLab-陈鑫杰
PingingLab微信公众号:pinginglab
PingingLab技术交流群:240920680
转载于:https://blog.51cto.com/chenxinjie/1274510