实验4-1:配置和调试单区域OSPF
【实验目的】:
在本次实验中,你将在你的机架中配置单区域OSPF。
在完成本次实验之后,你需要完成下列任务:
- 配置单区域OSPF
- 配置一个稳定的OSPF路由器ID(RID)
【实验拓扑】:
注意:图中x为所在机架编号,y为路由器编号。
【实验帮助】:
如果出现任何问题,可以向在值的辅导老师提出并请求提供帮助。
【命令列表】:
命令
|
描述
|
#clear ip ospf process
|
重置OSPF进程
|
#debug ip ospf events
|
调试OSPF进程事件的进展
|
#show ip ospf
|
显示OSPF进程参数
|
#show ip ospf neighbor
|
显示所有的OSPF邻居
|
(config)#router ospf 1
|
开启OSPF,这个进程号仅是本地有效。
|
(config-if)#ip ospf priority 0
|
指定该接口上的OSPF优先级为0,使其不能被选为DR和BDR
|
(config-router)#network 10.x0.0 0.0.255.255 area 1
|
指定运行OSPF的接口
|
(config-router)#router-id 10.0.0 .xy
|
配置OSPF的路由器ID(RID)。
|
【任务一】:配置单区域OSPF。
实验之前,请确保你的路由器配置与下列类似:
P1R1
或P1R2:
hostname P1R1
!
boot-start-marker
boot-end-marker
!
no aaa new-model
ip subnet-zero
no ip domain lookup
!
interface Ethernet0
ip address 10.1.1 .1 255.255.255.0
!
interface Serial0
ip address 172.31.1.1 255.255.255.0
encapsulation frame-relay
frame-relay map ip 172.31.1.3 111 broadcast
no frame-relay inverse-arp
!
interface Serial1
ip address 10.1.0.1 255.255.255.0
clock rate 64000
!
no ip http server
ip classless
!
line con 0
exec-timeout 30 0
logging synchronous
line aux 0
line vty 0 4
login
!
End
P1R3
或P1R4:
hostname P1R3
!
boot-start-marker
boot-end-marker
!
no aaa new-model
ip subnet-zero
!
interface Ethernet0
ip address 10.1.1.3 255.255.255.0
!
interface Serial0
ip address 10.1.3.3 255.255.255.0
clock rate 64000
!
interface Serial1
no ip address
shutdown
!
no ip http server
ip classless
!
line con 0
line aux 0
line vty 0 4
!
end
实验过程:
第一步:关闭帧中继连接(边界路由器PxR1和PxR2的s0接口)
第二步:在你的路由器上配置OSPF运行区域x。在这里x是你的机架号。为了避免在以后的实验中出现问题,使用你的网络编号10.x.0.0,而不是整个网络 10.0.0 .0。
第三步:使用适当的show ip ospf命令验证你的OSPF路由器的RID。此时,这个RID应该是当前激活的最高IP地址。注意路由器R1和R2并没有选择帧中继IP地址,因为这个接口是没有激活的。
你的路由器运行的哪一个OSPF RID,你希望的RID又是什么呢?
PxR1的RID:
PxR2的RID:
PxR3的RID:
PxR4的RID:
第四步:配置PxR3和PxR4的环回接口0 IP地址为10.200.200.xy/32,x是你的机架编号,y是你的路由器编号。
第五步:使用适当的show命令验证内部路由器的OSPF RID。这个RID应该是最高的环回接口地址。如果这里没有环回接口地址,那么就是最高的激活IP地址。你的内部路由器现在运行的RID是什么,你希望使用的RID又是什么?
PxR3的RID:
PxR4的RID:
第六步:注意先前的RID并没有更改,稳定的RID是CISCO IOS的一个特性。如果RID是更改的,这个链路状态广播(LSA)将是无效的,路由器就需要重新收敛。在OSPF进程是配置以后配置环回接口,需要重新启动路由器使新的RID生效。
第七步:路由器重启以后使用适当的show命令验证内部路由器的OSPF RID已经更改为环回接口0(lo0)。
第八步:在路由器PxR1和PxR2上,在OSPF进程下使用router-id命令设置OSPF RID为 10.0.0 .xy,x是你的机架编号,y是你的路由器编号。在特权模式下使用clear ip ospf process命令重置OSPF进程,使router-id命令生效。这router-id是另外一种方法去设置OSPF路由器的RID。这个命令仅在12.0(1)和以后的IOS中有效。
- 注意: 为了通过配置环回接口的方式更改路由器的OSPF ID需要重新启动路由器或者关闭OSPF然后重新激活OSPF。为了通过通过在OSPF进程下配置RID更改路由器的OSPFID,只需要重置OSPF进程就可以了。
第九步:重置OSPF进程后,使用适当的show命令验证边界路由器的RID已经更改为 10.0.0 .xy。
第十步:在完成配置之前,确定所有的OSPF邻居是在相互通讯的(进入FULL状态),这样可以避免在以后的LAB出现问题。
第十一步:查看IP路由表确定有学习到OSPF路由
【任务二】:理解OSPF的包类型
实验过程:
第一步:使用debug ip ospf events命令检查OSPF包类型。
第二步:重置OSPF进程并检查OSPF邻接建立和选择DR和BDR。你的显示应该与下列类似:
P1R2#debug ip ospf event
OSPF events debugging is on
P1R2#clear ip os pro
Reset ALL OSPF processes? [no]: y
P1R2#
*Mar 1 00:27:23.923: OSPF: Flushing External Links
*Mar 1 00:27:23.927: OSPF: Flushing Opaque AS Links
*Mar 1 00:27:23.963: OSPF: Flushing Link states in area 1
*Mar 1 00:27:24.003: OSPF: Interface Ethernet0 going Down
*Mar 1 00:27:24.007: OSPF: Neighbor change Event on interface Ethernet0
*Mar 1 00:27:24.007: OSPF: DR/BDR election on Ethernet0
*Mar 1 00:27:24.011: OSPF: Elect BDR 0.0.0 .0
*Mar 1 00:27:24.011: OSPF: Elect DR 10.200.200.14
*Mar 1 00:27:24.015: OSPF: Elect BDR 0.0.0.0
*Mar 1 00:27:24.015: OSPF: Elect DR 10.200.200.14
*Mar 1 00:27:24.019: DR: 10.200.200.14 (Id) BDR: none
*Mar 1 00:27:24.023: %OSPF-5-ADJCHG: Process 1, Nbr 10.200.200.14 on Ethernet0
from FULL to DOWN, Neighbor Down: Interface down or detached
P1R2#
*Mar 1 00:27:24.027: OSPF: Neighbor change Event on interface Ethernet0
*Mar 1 00:27:24.031: OSPF: DR/BDR election on Ethernet0
*Mar 1 00:27:24.031: OSPF: Elect BDR 0.0.0.0
*Mar 1 00:27:24.035: OSPF: Elect DR 0.0.0.0
*Mar 1 00:27:24.035: DR: none BDR: none
*Mar 1 00:27:24.039: OSPF: Remember old DR 10.200.200.14 (id)
*Mar 1 00:27:24.235: OSPF: i_up : interface is down
*Mar 1 00:27:24.239: OSPF: Interface Ethernet0 going Up
*Mar 1 00:27:24.239: OSPF: Send hello to 224.0.0.5 area 1 on Ethernet0 from 10.
1.2.2
P1R2#
ar 1 00:27:28.699: OSPF: Rcv hello from 10.200.200.14 area 1 from Ethernet0 1
0.1.2.4
*Mar 1 00:27:28.703: OSPF: 2 Way Communication to 10.200.200.14 on Ethernet0, s
tate 2WAY
*Mar 1 00:27:28.707: OSPF: Backup seen Event before WAIT timer on Ethernet0
*Mar 1 00:27:28.707: OSPF: DR/BDR election on Ethernet0
*Mar 1 00:27:28.711: OSPF: Elect BDR 10.1.0.2
*Mar 1 00:27:28.711: OSPF: Elect DR 10.200.200.14
*Mar 1 00:27:28.715: OSPF: Elect BDR 10.1.0.2
*Mar 1 00:27:28.719: OSPF: Elect DR 10.200.200.14
*Mar 1 00:27:28.719: DR: 10.200.200.14 (Id) BDR: 10.1.0.2 (Id)
P1R2#
*Mar 1 00:27:28.723: OSPF: Send DBD to 10.200.200.14 on Ethernet0 seq 0x 1A 42 op
t 0x52 flag 0x7 len 32
*Mar 1 00:27:28.731: OSPF: End of hello processing
P1R2#
*Mar 1 00:27:33.727: OSPF: Send DBD to 10.200.200.14 on Ethernet0 seq 0x 1A 42 op
t 0x52 flag 0x7 len 32
*Mar 1 00:27:33.731: OSPF: Retransmitting DBD to 10.200.200.14 on Ethernet0 [1]
*Mar 1 00:27:33.743: OSPF: Rcv DBD from 10.200.200.14 on Ethernet0 seq 0x246E o
pt 0x52 flag 0x7 len 32 mtu 1500 state EXSTART
*Mar 1 00:27:33.747: OSPF: NBR Negotiation Done. We are the SLAVE
*Mar 1 00:27:33.747: OSPF: Send DBD to 10.200.200.14 on Ethernet0 seq 0x246E op
t 0x52 flag 0x2 len 52
*Mar 1 00:27:33.767: OSPF: Rcv DBD from 10.200.200.14 on Ethernet0 seq 0x 246F o
pt 0x52 flag 0x3 len 112 mtu 1500 state EXCHANGE
*Mar 1 00:27:33.771: OSPF: Send DBD to 10.200.200.14 on Ethernet0 seq 0x 246F op
t 0x52 flag 0x0 len 32
*Mar 1 00:27:33.779: OSPF: Database request to 10.200.200.14
*Mar 1 00:27:33.783: OSPF: sent LS REQ packet to 10.1.2.4, length 48
*Mar 1 00:27:33.791: OSPF: Rcv DBD from 10.200.200.14 on Ethernet0 seq 0x2470 o
pt 0x52 flag 0x1 len 32 mtu 1500 state EXCHANGE
*Mar 1 00
P1R2#:27:33.795: OSPF: Exchange Done with 10.200.200.14 on Ethernet0
*Mar 1 00:27:33.799: OSPF: Send DBD to 10.200.200.14 on Ethernet0 seq 0x2470 op
t 0x52 flag 0x0 len 32
*Mar 1 00:27:33.815: OSPF: Synchronized with 10.200.200.14 on Ethernet0, state
FULL
*Mar 1 00:27:33.819: %OSPF-5-ADJCHG: Process 1, Nbr 10.200.200.14 on Ethernet0
from LOADING to FULL, Loading Done
*Mar 1 00:27:34.243: OSPF: Send hello to 224.0.0.5 area 1 on Ethernet0 from 10.
1.2.2
P1R2#
*Mar 1 00:27:38.699: OSPF: Rcv hello from 10.200.200.14 area 1 from Ethernet0 1
0.1.2.4
*Mar 1 00:27:38.703: OSPF: Neighbor change Event on interface Ethernet0
*Mar 1 00:27:38.707: OSPF: DR/BDR election on Ethernet0
*Mar 1 00:27:38.707: OSPF: Elect BDR 10.1.0.2
*Mar 1 00:27:38.711: OSPF: Elect DR 10.200.200.14
*Mar 1 00:27:38.711: DR: 10.200.200.14 (Id) BDR: 10.1.0.2 (Id)
*Mar 1 00:27:38.715: OSPF: End of hello processing
P1R2#
*Mar 1 00:27:44.247: OSPF: Send hello to 224.0.0.5 area 1 on Ethernet0 from 10.
1.2.2
P1R2#
*Mar 1 00:27:48.703: OSPF: Rcv hello from 10.200.200.14 area 1 from Ethernet0 1
0.1.2.4
*Mar 1 00:27:48.707: OSPF: End of hello processing
P1R2#
*Mar 1 00:27:54.251: OSPF: Send hello to 224.0.0.5 area 1 on Ethernet0 from 10.
1.2.2
P1R2#
【任务四】:理解发DR和BDR 选择
实验过程:
第一步: 使用show ip os neighbor命令确定路由器的缺省优先级和哪一个路由器是以太网网段DR。
第二步:在适当的路由器的以太网接口更改OSPF的优先级为0以更改DR的选择。更改OSPF的优先级为0将使该接口不具备DR选择的权利。在边界路由器上观察DR的选择过程(debug ip ospf events仍在运行)
*Mar 1 01:03:18.731: OSPF: Neighbor change Event on interface Ethernet0
*Mar 1 01:03:18.735: OSPF: DR/BDR election on Ethernet0
*Mar 1 01:03:18.735: OSPF: Elect BDR 10.1.0 .2
*Mar 1 01:03:18.739: OSPF: Elect DR 10.1.0.2
*Mar 1 01:03:18.739: OSPF: Elect BDR 0.0.0.0
*Mar 1 01:03:18.743: OSPF: Elect DR 10.1.0.2
*Mar 1 01:03:18.743: DR: 10.1.0.2 (Id) BDR: none
*Mar 1 01:03:18.747: OSPF: Remember old DR 10.200.200.14 (id)
*Mar 1 01:03:18.751: OSPF: End of hello processing
P1R2#
*Mar 1 01:03:21.975: OSPF: Send hello to 224.0.0.5 area 1 on Ethernet0 from 10.
1.2.2
P1R2#
*Mar 1 01:03:28.727: OSPF: Rcv hello from 10.200.200.14 area 1 from Ethernet0 1
0.1.2.4
*Mar 1 01:03:28.731: OSPF: Neighbor change Event on interface Ethernet0
*Mar 1 01:03:28.735: OSPF: DR/BDR election on Ethernet0
*Mar 1 01:03:28.735: OSPF: Elect BDR 0.0.0.0
*Mar 1 01:03:28.739: OSPF: Elect DR 10.1.0.2
*Mar 1 01:03:28.739: DR: 10.1.0.2 (Id) BDR: none
*Mar 1 01:03:28.743: OSPF: End of hello processing
P1R2#
第三步:DR和BDR选择完成以后,关闭DEBUG调试。
第四步:显示OSPF邻居数据库,验证DR的选择结果。
P1R2#sh ip os neighbor
Neighbor ID Pri State Dead Time Address Interface
10.1.0 .1 0 FULL/ - 00:00:37 10.1.0.1 Serial1
10.200.200.14 0 FULL/DROTHER 00:00:37 10.1.2.4 Ethernet0
【实验验证】:
成功完成整个实验,你需要完成下列任务:
- 你有成功的配置OSPF。
- 你理解了怎样控制RID。
- 你能够验证OSPF邻居的形成。
- 你能够管理DR和BDR的选择。
【路由器配置】:
P1R1
:
hostname P1R1
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
ip subnet-zero
no ip domain lookup
!
!
!
!
interface Ethernet0
ip address 10.1.1 .1 255.255.255.0
!
interface Serial0
ip address 172.31.1.1 255.255.255.0
encapsulation frame-relay
shutdown
frame-relay map ip 172.31.1.3 111 broadcast
no frame-relay inverse-arp
!
interface Serial1
ip address 10.1.0.1 255.255.255.0
clockrate 64000
!
router ospf 1
router-id 10.1.0.1
log-adjacency-changes
network 10.1.0.0 0.0.255.255 area 1
!
no ip http server
ip classless
!
!
!
!
line con 0
exec-timeout 30 0
logging synchronous
line aux 0
line vty 0 4
login
!
!
end
P1R2:
hostname P1R2
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
ip subnet-zero
no ip domain lookup
!
!
!
!
interface Ethernet0
ip address 10.1.2.2 255.255.255.0
!
interface Serial0
ip address 172.31.1.2 255.255.255.0
encapsulation frame-relay
shutdown
frame-relay map ip 172.31.1.3 112 broadcast
no frame-relay inverse-arp
!
interface Serial1
ip address 10.1.0.2 255.255.255.0
!
router ospf 1
router-id 10.1.0.2
log-adjacency-changes
network 10.1.0.0 0.0.255.255 area 1
!
no ip http server
ip classless
!
!
!
!
line con 0
exec-timeout 30 0
logging synchronous
line aux 0
line vty 0 4
login
!
!
end
P1R3
:
hostname P1R3
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
ip subnet-zero
!
!
!
!
interface Loopback0
ip address 10.200.200.13 255.255.255.255
!
interface Ethernet0
ip address 10.1.1 .3 255.255.255.0
!
interface Serial0
ip address 10.1.3.3 255.255.255.0
clockrate 64000
!
interface Serial1
no ip address
shutdown
!
router ospf 1
log-adjacency-changes
network 10.1.0.0 0.0.255.255 area 1
!
no ip http server
ip classless
!
!
!
!
line con 0
line aux 0
line vty 0 4
login
!
!
End
P1R4
:
hostname P1R4
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
ip subnet-zero
!
!
!
!
interface Loopback0
ip address 10.200.200.14 255.255.255.255
!
interface Ethernet0
ip address 10.1.2 .4 255.255.255.0
ip ospf priority 0
!
interface Serial0
ip address 10.1.3.4 255.255.255.0
!
interface Serial1
no ip address
shutdown
!
router ospf 1
log-adjacency-changes
network 10.1.0.0 0.0.255.255 area 1
!
no ip http server
ip classless
!
!
!
!
line con 0
line aux 0
line vty 0 4
login
!
!
end
本文出自 “butter520” 博客,转载请与作者联系!