配置和查看 OSPF
协议
离婚协议模板下载合伙人协议 下载渠道分销协议免费下载敬业协议下载授课协议下载
本实验是对OSPF协议的基本配置,涉及到配置OSPF协议所必须的命令和常用的show命令。
通过本实验,读者可以掌握以下技能:
?在路由器上启动OSPF协议;
?声明相应网络进入OSPF路由进程;
?查看OSPF路由信息;
?查看OSPF协议配置信息;
?查看OSPF邻居路由器信息。
本实验需要以下设备:
?Cisco路由器3台,分别命名为R1。R2和R3,其中R2要求具有2个串行接口,R1和R3均要求具有1个串行接口和1个以太网接口;
?2条DCE电缆和2条DTE电缆 (或2条DCE转DTE电缆);
?1台终端服务器,如Cisco 2509路由器,及用于反向Telnet的相应电缆;
?4台带有超级终端程序的PC机,以及Console电缆及转接器。
本实验的拓扑结构如图11-1所示,利用DCE和DTE电缆把R1。R2和R3路由器连接起来。各路由器使用的接口及其编号如图11-1中的标注。
各接口IP地址分配如下:
R1:S1 192.168.1.130,E0 172.16.1.1/24
R2:S0 192.168.1.5/30,S1 192.168.1.2/30
R3:S0 192.168.1.6/30,E0 172.16.3.1/24
实验中R1、R2之间串行线路速率设置为 125kbit/s;R2、R3之间串行线路
速率设置为64kbit/s。
本实验要求通过对OSPF路由选择协议的配置,实现拓扑中全网的连通性。
按照拓扑结构图连接好所有设备后,给设备加电,开始进行实验。
首先对各路由器的接口和OSPF协议进行配置。配置
清单
安全隐患排查清单下载最新工程量清单计量规则下载程序清单下载家私清单下载送货清单下载
11-1
记录
混凝土 养护记录下载土方回填监理旁站记录免费下载集备记录下载集备记录下载集备记录下载
了对3
台路由器的配置。
第1段:配置R1路由器
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#no logg console
Router(config)#hostn R1
R1(config)#int e0
R1(config-if)#no keepa
R1(config-if)#ip addr 172.16.1.1255.255.255.0
R1(config-if)#no sh
R1(config-if)#
R1(config-if)#int s1
R1(config-if)#ip addr 192.168.1.1255.255.255.252
R1(config-if)#clock rate 125000
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#router ospf 100
R1(config-router)#network 192.168.1.1 0.0.0.0 area 0
R1(config-router)#network 172.16.1.1 0.0.0.0 area 0
R1(config-router)#^Z
R1#
第2段:配置R2路由器
Term_Server#2
[Resuming connection 2 to r2 ... ]
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#no logg console
Router(config)#shostn R2
R2(config)#int s0
R2(config-if)#ip addr 192.168.1.5 255.255.255.252
R2(config-if)#no sh
R2(config-if)#int s1
R2(config-if)#ip addr 192.168.1.2 255.255.255.252
R2(config-if)#no sh
R2(config-if)#exit
R2(config)#router ospf 100
R2(config-router)#netw 192.168.1.2 0.0.0.0 area 0
R2(config-router)#netw 192.168.1.5 0.0.0.0 area 0
R2(config-router)#^Z
R2#
第3段:配置R3路由器
Term_Server#3
[Resuming connection 3 to r3 ... ]
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#no logg console
Router(config)#shostn R3
R3(config)#int s0
R3(config-if)#ip addr 192.168.1.6 255.255.255.252
R3(config-if)#clock rate 64000
R3(config-if)#no shut
R3(config)#int e0
R3(config-if)#no keepa
R3(config-if)#ip addr 172.16.3.1255.255.255.0
R3(config-if)#no sh
R3(config-if)#exit
R3(config)#router ospf 100
R3(config-router)#netw 192.168.1.6 0.0.0.0 area 0
R3(config-router)#netw 172.16.3.1 0.0.0.0 area 0
R3 (config-router)#exit
R3(config-if)#^Z
R3#
(1)在上述配置中,首先对每台路由器的接口进行了配置。需要注意以下两
点:
在配置串行接口时,应按照接口所连接的电缆类型,对连接DCE电缆的接口
配置时钟;
在配置以太网接口时,使用了no keepalive命令,以便在不连接网线的情
况下,使接口处于激活状态。
(2)router ospf 100命令启动一个OSPF路由选择协议进程(Process),其中的"100"为进程号。与配置IGRP和EIGRP协议中的AS号不同的是,在配置OSPF时,并不需要每台路由器中的进程号一致。AS和进程是完全不同的两个概念。
(3)network命令使相应酌网段加入OSPF路由进程中,其格式为:
network网络地址(或IP地址)通配码area区域号
在本实验的配置中,使用了相应接口IP地址,并且把通配码写成"0.0.0.0",区域号为0,即主干区域。
在OSPF的配置中,只要把接口加入到OSPF进程中,此接口所对应的网段就
加入到OSPF路由进程中了。
(4)对于另外2台路由器重复类似的配置,完成OSPF协议的基本配置。
第2部分:查看IP路由表和测试连通性
下面对配置后的各路由器进行查看和测试,看是否实现了全网的连通。
在这一部分,我们使用了show ip route、ping、trace等命令。
监测清单11-1记录了所有的操作及其结果。
R3#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B
- BGP
D - EIGRP, EX - EIGRP external, 0 - 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, E - EGP
i - IS-IS, 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
172.16.0.0/24 is subnetted, 2 subnets
O 172.16.1.0[110/138]via 192.168.1.5,00:00:21,Serial0
C 172.16.3.0 is directly connected, Ethernet0
192.168.1.0/30 is subnetted, 2 subnets
O 192.168.1.0[110/128]via 192.168.1.5,00:00:21,Serial0
C 192.168.1.4 is directly connected, Serial0
R3#
Term_Server#2
[Resuming connection 2 to r2 ... ]
R2#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B
- BGP
D - EIGRP, EX - EIGRP external, 0 - 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, E - EGP
i - IS-IS, 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
172.16.0.0/24 is subnetted, 2 subnets
O 172.16.1.0 [110/74] via 192.168.1.1,00:00:43,Serial1
O 172.16.3.0 [110/74] via 192.168.1.6,00:00:43,Serial0
192.168.1.0/30 is subnetted, 2 subnets
C 192.168.1.0 is directly connected, Serial1
C 192.168.1.4 is directly connected, Serial0
R2#ping 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-tdp min/avg/max =16/18/20
ms
R2#ping 172.163.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent(5/5),round-trip min/avg/max=28/31/32 ms
R2#
(1)首先在R3路由器上使用show ip route命令查看其IP路由表,可以看到有2条行首标注为"O"的路由项,它们就是由OSPF协议学习到的路由。这2条路由的目的网段分别为172.16.1.0/24和192.168.1.0/30,它们的下一跳点均为192.168.1.5(R2 S0接口)。
在第1个路由表项中有"[110/138]"字段,其中110是OSPF的缺省管理距离,138则是本条路由的Cost。Cost即费用,是OSPF中的度量值
标准
excel标准偏差excel标准偏差函数exl标准差函数国标检验抽样标准表免费下载红头文件格式标准下载
,路由器用Cost来比较到达同一目的网段的不同路径的耗费。低的Cost表示是好的路径,相反则是差的路径。
(2)接下来切换到R2路由器的控制台界面上,show ip route命令显示有2条OSPF路由,它们分别是通过192.168.1.1(R1 S1接口)到达172.16.1.0/24网段和通过192.168.1.6(R3 S0接口)到达172.16.3.0/24网段的路由项。
(3)在R2路由器上分别间172.16.1.1和172.16.3.1发出了ping测试,结果是成功的。
(4)在R1路由器上查看路由表,同样得到2条OSPF路由,分别指向目的网段172.16.3.0/24和192.168.1.4/30,其网关地址均为192.168.1.2(R2 S1接口)。
(5)为测试172.16.1.0/24网段到172.16.1.0/24网段的端到端连通性,我们使用了扩
展的ping命令。测试结果是成功的,表明从R1的E0接口到R3的E0接口之间是在IP层
是正常连通的。
(6)接下来的trace命令测试了从R1到R3的E0接口所经过的各个网关,它们依次是192.168.1.2和192.168.1.6。
3:OSPF
下面使用有关命令查看OSPF协议的配置、邻居、接口和路由等信息。
监测清单11-2记录了所使用的命令和相应的结果。
11-2OSPF
R2#sh ip protocol
Routing Protocol is "ospf 100"
Invalid after 0 seconds, hold down 0, flushed after 0
Outgoing update filter list for all interfaces is
Incoming update filter list for all interfaces is
Routing for Networks:
192.168.1.2/32
192,168.1.5/32
Routing Infottuation Sources:
Gateway Distance Last Update
192.168.1.1 110 00:09:26
192.168.1.6 110 00:09:26
Distance: (default is 110)
R2#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
192.168.1.6 1 FULL/ - 00:00:34 192.168.1.6 Serial0
192.168.1.1 1 FULL/ - 00:00:36 192.168.1.1 Serial1
R2#sh ip ospf neighbor detail
Neighbor
In the area 0 via interface Serial0
Neighbor priority is 1,State is FULL,6 state changes
DR is 0.0.0.0 BDR is 0.0.0.0
Options is 0x42
Dead timer-due in 00:00:38
Neighbor is up for 00:10:40
Index 2/2, retransmission queue length 0, number of retransmission 1
First 0x0(0/0x0(0) Next 0x0(0)/0x0(0)
Last retransmission scan length is 1, maximum is 1
Last retransmission scan time is 0 msec, maximum is 0 msec
Neighbor 192.168.1.1,interface address 192.168.1.1
In the area 0 via interface Serial 1
Neighbor priority is 1,State is FULL, 6 state changes
DR is 0.0.0.0 BDR is 0.0.0.0
Options is 0x42
Dead timer due in 00:00:39
Neighbor is up- for 00:10:50
Index 1/1, retransmission queue length 0, number of retransmission 1
First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
Last retransmission scan length is 1, maximum is 1
Last retransmission scan time is 0 msec, maximum is 0 msec
R2#sh ip ospf interface s0
Serial0 is up, line protocol is up
Internet Address 192.168.1.5/30, Arca0
Proems ID 100, Router ID 192.168.1.5,Network Type POINT_TO_POINT,Cost:64
Transmit Delay is 1 sec. State POINT_TO_POINT,
Timer ititervals configured Hello 10,1>ead 40, Wait 40, Retransmit 5
Hello due in 00:00:00
Index 2/2, 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 192.168.1.6
Suppress hello for 0 neighbor(s)
R2#sh ip ospf database
OSPF Router with ID (192.168.1.5) (Process ID 100)
Router Link States(Area 0)
Link ID ADV Router Age Seq# Checksum Link
count
192.168.1.1 192.168.1.1 832 0x80000005 0xF6B8 3
192.168.1.5 192.168,1.5 820 0x80000006 0xF6B8 4
192.168.1.6 192.168.1.6 806 0x80000005 0xF6B8 3
R2#
Term_Server>1
[Resuming connection 1 to r1 ... ]
R1#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
192.168.1.5 1 FULL/- 00:00:36 192.168.1.2 Serial1
R1#
Term_Server>3
[Resuming connection 3 to r3...]
R3#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
192.168.1.5 1 FULL/- 00:00:35 192.168.1.5 Serial0
R3#sh ip route ospf
172.16.0.0/24 is subnetted,2 subnets
O 172.16.1.0[110/138]via 192.168.1.5,00:12:12,Serial0
192.168.1.0/30 is subnetted,2 subnets
O 192.168.1.0[110/128]via 192.168.1.5,00:12:12,Serial0
R3#sh ip route 172.16.1.0
Routing entry for 172.16.1./24
Known via"ospf 100",distance 110,metric 138,type intra area
Last update from 192.168.1.5 on Serial0,00:12:20 ago
Routing Descriptor Blocks:
* 192J68.1.5, from 192.168.1.1, 00:12:20 ago, via Serial0
Route metric is 138, traffic share count is 1
(1)在R2路由器上,使用show ip protocol命令,可以列出OSPF协议的主要配置信息。其中所路由的网络中列出的是接口地址"掩码为32位,这是和网络声明配置语句相对应的。
命令同时列出了2个路由信息源,它们是R1和R3路由器,相应的IP地址即为R1和R3的RouterID。
OSPF协议的缺省管理距离为110。
(2)show ip ospf neighbor命令列出了当前路由器的邻居,其中各项的含义如下:
NeighborID:邻居路由器的ID号;
Pri:即Priority,邻居路由器的优先级,缺省情况下是1;
State:邻居路由器的状态,"Full"表明形成的完全的邻接关系;
Dead Time:为终结时间,如果在此计数器计数到0之前,没有接收到由对应的邻居路由器发来的Hello包,则邻接关系将被清除;
Address:是邻居路由器的IP地址;
Interface:是与邻居路由器相连的本路由器的接口。
(3)使用show ip ospf neghbor detail命令列出了与R2路由器相邻的路由器的详细信息。
(4)show ip ospf interface命令可以列出相应接口的OSPF信息。以R2路由器S0接
口为例,列出了以下重要信息:
OSPF进程ID为100;
RouterID为192.168.1.5;
OSPF网络类型为点到点;
此链路的Cost值为64;
Hello计时器为10秒;
终结计时器为40秒;
等待计时器为40秒;
与一个邻居路由器形成邻接关系,它的ID是192.168.1.6,即R3路由器。
(5)查看OSPF数据库的命令是show ip ospf database,此命令列出了3条链路信息,分别是由R1、R2和R3产生的。
(6)在R1和R3路由器上查看OSPF邻居信息,可以看到它们的邻居都是R2。
(7)使用show ip route ospf命令可以查看由OSPF协议所得到的路由项,便我们在众
多路由项中找到想看的OSPF路由项。
(8)使用带有网段参数的show ip route命令可以查看相应的网段(如实验中的172.16.1.0)的详细信息,包括由什么协议获取、度量值、路由源及更新时间等信息。