CCNA配置试验之四OSPF协议的配置
3935 点击·0 回帖
![]() | ![]() | |
![]() | OSPF协议概述 链路状态路由协议对以下信息进行跟踪: 1.邻居信息 2.本区域里的所有路由器 3.到达目标网络的最佳路径 三表: 邻居表: 邻居路由器的信息 拓扑表: 也叫链路状态数据库 路由表: 到达目标网络的最佳路径 OSPF引入了区域的概念,区域分2种: 1.骨干区域(area 0) 2.常规区域 注意,所有的常规区域必须和骨干区域相连 OSPF的邻接关系的建立是依赖于hello包的 DR/BDR选举规则: ? 当选举DR/BDR 的时候要比较hello 包中的优先级(priority),优先级最高的为DR,次高的为BDR.默认优先级都为1.在优先级相同的情况下就比较RID,RID 等级最高的为DR,次高的为BDR.当你把优先级设置为0 以后,OSPF 路由器就不能成为DR/BDR,只能成为DROTHER ? DR/BDR选举完成后,DRother只和DR/BDR形成邻接关系.所有的路由器将组播Hello包到地址224.0.0.5以便它们能跟踪其他邻居的信息,即DR将洪泛LSU到224.0.0.5;DRother只组播LSU到AllDRouter地址224.0.0.6,只有DR/BDR监听这个地址 OSPF的优点 ? 1.对网络发生的变化能够快速响应 ? 2.当网络发生变化的时候发送触发式更新(triggered update) ? 3.支持VLSM ? 4.方便管理 配置单区域的 OSPF Router(config)#router ospf process-id 启用OSPF Router(config-router)#network address wild card bits area area-id 将网段指派到指定的区域中 试验配置单区域的OSPF。 ![]() 试验环境介绍: R1的ip地址为192.168.6.2 (E1/0) 192.168.7.1 (S0/0) 网络掩码为255.255.255.0 R2的ip地址为 192.168.7.2 (S0/0) 192.168.8.1(S0/1) 网络掩码为255.255.255.0 R3的ip地址为192.168.8.2 (S0/1) 192.168.9.1(E1/0) 网络掩码为255.255.255.0 R1的S0/0 R2的S0/1 为DCE端 PC1的ip地址为192.168.6.1 网络掩码为 255.255.255.0 PC2的ip地址为192.168.9.2 网络掩码为 255.255.255.0 process-id为100 area号为0 试验要求: 通过在路由器间配置单区域的OSPF协议,使PC1和PC2之间相互ping通。即实现全网全通。 开始工作了(红的字体为配置内容) R1 Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#host r1 r1(config)#int e1/0 r1(config-if)#ip addr 192.168.6.2 255.255.255.0 r1(config-if)#no shut r1(config-if)#exit r1(config)#int s0/0 r1(config-if)#ip addr 192.168.7.1 255.255.255.0 r1(config-if)#clock rate 64000 r1(config-if)#no shut r1(config-if)#exit r1(config)#router ospf 100 r1(config-router)#network 192.168.6.2 0.0.0.0 area 0 r1(config-router)#network 192.168.7.1 0.0.0.0 area 0 R2 Router>en Router#conf Enter configuration commands, one per line. End with CNTL/Z. Router(config)#host r2 r2(config)#int s0/0 r2(config-if)#ip addr 192.168.7.2 255.255.255.0 r2(config-if)#no shut r2(config-if)#exit r2(config)#int s0/1 r2(config-if)#ip addr 192.168.8.1 255.255.255.0 r2(config-if)#clock rate 64000 r2(config-if)#no shut r2(config-if)#exit r2(config)#router ospf 100 r2(config-router)#network 192.168.7.2 0.0.0.0 area 0 r2(config-router)#network 192.168.8.1 0.0.0.0 area 0 R3 Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#host r3 r3(config)#int s0/1 r3(config-if)#ip addr 192.168.8.2 255.255.255.0 r3(config-if)#no shut r3(config-if)#exit r3(config)#int e1/0 r3(config-if)#ip addr 192.168.9.1 255.255.255.0 r3(config-if)#no shut r3(config-if)#exit r3(config)#router ospf 100 r3(config-router)#network 192.168.8.2 0.0.0.0 area 0 r3(config-router)#network 192.168.9.1 0.0.0.0 area 0 PC机的配置 VPCS 1 >ip 192.168.6.1 192.168.6.2 PC1 : 192.168.6.1 255.255.255.0 gateway 192.168.6.2 VPCS 1 >2 VPCS 2 >ip 192.168.9.2 192.168.9.1 PC2 : 192.168.9.2 255.255.255.0 gateway 192.168.9.1 如下是PC1和 PC2相互ping的结果,结果表明,全网全通 VPCS 2 >ping 192.168.6.1 192.168.6.1 icmp_seq=1 timeout 192.168.6.1 icmp_seq=2 time=157.000 ms 192.168.6.1 icmp_seq=3 time=297.000 ms 192.168.6.1 icmp_seq=4 time=172.000 ms 192.168.6.1 icmp_seq=5 time=172.000 ms VPCS 2 >ping 192.168.9.2 192.168.9.2 icmp_seq=1 time =157.000 ms 192.168.9.2 icmp_seq=2 time=157.000 ms 192.168.9.2 icmp_seq=3 time=297.000 ms 192.168.9.2 icmp_seq=4 time=172.000 ms 192.168.9.2 icmp_seq=5 time=172.000 ms 下面是分别在R1 R2 R3 上show ip route 查看的路由协议,结果表明路由器间是通过OSPF协议实现全网全通的。 R1 r1#show ip protocols Routing Protocol is "ospf 100" Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Router ID 192.168.7.1 Number of areas in this router is 1. 1 normal 0 stub 0 nssa Maximum path: 4 Routing for Networks: 192.168.6.2 0.0.0.0 area 0 192.168.7.1 0.0.0.0 area 0 Reference bandwidth unit is 100 mbps Routing Information Sources: Gateway Distance Last Update 192.168.9.1 110 00:04:49 192.168.8.1 110 00:04:49 Distance: (default is 110) R2 r2>show ip protocols Routing Protocol is "ospf 100" Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Router ID 192.168.8.1 Number of areas in this router is 1. 1 normal 0 stub 0 nssa Maximum path: 4 Routing for Networks: 192.168.7.2 0.0.0.0 area 0 192.168.8.1 0.0.0.0 area 0 Reference bandwidth unit is 100 mbps Routing Information Sources: Gateway Distance Last Update 192.168.9.1 110 00:05:23 192.168.7.1 110 00:05:23 Distance: (default is 110) R3 r3#show ip protocols Routing Protocol is "ospf 100" Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Router ID 192.168.9.1 Number of areas in this router is 1. 1 normal 0 stub 0 nssa Maximum path: 4 Routing for Networks: 192.168.8.2 0.0.0.0 area 0 192.168.9.1 0.0.0.0 area 0 Reference bandwidth unit is 100 mbps Routing Information Sources: Gateway Distance Last Update 192.168.8.1 110 00:06:20 192.168.7.1 110 00:06:20 Distance: (default is 110) OK 试验成功告终!!! 下面内容查看 OSPF 配置 Router#show ip protocols 查看启用的路由协议 Router#show ip route 查看路由表 Router#show ip ospf interface 查看区域号和与此相关的信息 Router#show ip ospf neighbor 查看在每一个接口上的邻居信息 | |
![]() | ![]() |