多路访问链路上的OSPF:
实验目的
通过本实验可以掌握:
(1)在路由器上启动 OSPF 路由进程
(2)启用参与路由协议的接口,并且通告网络及所在的区域
(3)DR选举的控制
(4)广播多路访问链路上的 OSPF 的特征
一、实验拓扑如图
二、配置ip,OSPF协议
r1#show ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.1.1 YES manual up up
FastEthernet0/1 unassigned YES unset administratively down down
Serial1/0 unassigned YES unset administratively down down
Serial1/1 unassigned YES unset administratively down down
Serial1/2 unassigned YES unset administratively down down
Serial1/3 unassigned YES unset administratively down down
Loopback0 1.1.1.1 YES manual up up
Vlan1 unassigned YES unset administratively down down
r1#
r1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
r1(config)#router ospf 1
r1(config-router)#network 192.168.1.0 0.0.0.255 area 0
r1(config-router)#network 1.1.1.0 0.0.0.255 area 0
r1(config-router)#end
r1#
R2,R3,R4进行同样的配置
三、实验调试
【技术要点】
(1)为了避免路由器之间建立完全邻接关系而引起的大量开销,OSPF要求在多路访问
的网络中选举一个 DR,每个路由器都与之建立邻接关系。选举 DR 的同时也选举出一个 BDR,
在 DR 失效的时候,BDR 担负起 DR 的职责,而且所有其它路由器只与 DR 和 BDR 建立邻接关
系;
(2)DR 和BDR 有它们自己的组播地址 224.0.0.6;
(3)DR 和 BDR 的选举是以各个网络为基础的,也就是说 DR 和 BDR 选举是一个路由器
的接口特性,而不是整个路由器的特性;
(4)DR 选举的原则:
① 首要因素是时间,最先启动的路由器被选举成 DR;
② 如果同时启动,或者重新选举,则看接口优先级(范围为 0-255) ,优先级最高的被
选举成 DR,默认情况下,多路访问网络的接口优先级为 1,点到点网络接口优先级为 0,修
改接口优先级的命令是“ ip ospf priority” ,如果接口的优先级被设置为 0,那么该接口将
不参与 DR 选举;
③ 如果前两者相同,最后看路由器 ID,路由器 ID 最高的被选举成 DR;
(5)DR 选举是非抢占的,除非人为地重新选举。重新选举 DR 的方法有两种,一是路
由器重新启动,二是执行“clear ip ospf process”命令。
r1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 2WAY/DROTHER 00:00:34 192.168.1.2 FastEthernet0/0
3.3.3.3 1 FULL/BDR 00:00:31 192.168.1.3 FastEthernet0/0
4.4.4.4 1 FULL/DR 00:00:39 192.168.1.4 FastEthernet0/0
r1#
我们可以看到,DR为R4,BDR为R3,R1和R2为其他路由器都与DR,BDR建立邻接关系,所以R1于R2的状态始终为2way。
r4#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
1.1.1.1 1 FULL/DROTHER 00:00:38 192.168.1.1 FastEthernet0/0
3.3.3.3 1 FULL/BDR 00:00:30 192.168.1.3 FastEthernet0/0
2.2.2.2 1 FULL/DROTHER 00:00:33 192.168.1.2 FastEthernet0/0
r4#
R4为指定路由器和R1,R2,R3建立邻接关系而且都已经达到了FULL的状态。
邻居关系和邻接关系是不能混为一谈的,邻居关系是指达到 2WAY 状态的两台路由器,而邻接关系是指达到 FULL 状态的两台路由器。
测试邻接关系的建立,以及DR,BDR的选举过程:
r4#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/BDR 00:00:39 192.168.1.2 FastEthernet0/0
1.1.1.1 2 FULL/DROTHER 00:00:30 192.168.1.1 FastEthernet0/0
3.3.3.3 1 FULL/DROTHER 00:00:32 192.168.1.3 FastEthernet0/0
r4# //之前的DR.BDR
r4#
r4#
r4#conf t
Enter configuration commands, one per line. End with CNTL/Z.
r4(config)#end
%SYS-5-CONFIG_I: Configured from console by console
r4#debug ip ospf adj
r4#debug ip ospf adj
OSPF adjacency events debugging is on
r4#conf t
Enter configuration commands, one per line. End with CNTL/Z.
r4(config)#int f0/0
r4(config-if)#shut
r4(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to administratively down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to down
00:46:35: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/0 from FULL to Down: Interface down or detached
00:46:35: OSPF: Build router LSA for area 0, router ID 4.4.4.4, seq 0x80000007
00:46:35: OSPF: Build net LSA for area 0, router ID 4.4.4.4, seq 0x8000000a
00:46:35: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on FastEthernet0/0 from FULL to Down: Interface down or detached
00:46:35: OSPF: Build router LSA for area 0, router ID 4.4.4.4, seq 0x80000008
00:46:35: OSPF: Build net LSA for area 0, router ID 4.4.4.4, seq 0x8000000b
00:46:35: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on FastEthernet0/0 from FULL to Down: Interface down or detached
00:46:35: OSPF: Build router LSA for area 0, router ID 4.4.4.4, seq 0x80000008
00:46:35: OSPF: No full nbrs to build Net Lsa for interface FastEthernet0/0
00:46:35: OSPF: DR/BDR election on FastEthernet0/0
00:46:35: OSPF: Elect BDR 0.0.0.0
00:46:35: OSPF: Elect DR 0.0.0.0
00:46:35: OSPF: Elect BDR 0.0.0.0
00:46:35: OSPF: Elect DR 0.0.0.0
00:46:35: DR: none BDR: none
00:46:35: OSPF: Build router LSA for area 0, router ID 4.4.4.4, seq 0x80000008
00:46:35: OSPF: Build router LSA for area 0, router ID 4.4.4.4, seq 0x80000008
r4(config-if)#
r4(config-if)#
r4(config-if)#
r4(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
r4(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
00:46:49: OSPF: Build router LSA for area 0, router ID 4.4.4.4, seq 0x80000008
r4(config-if)#end
r4#
%SYS-5-CONFIG_I: Configured from console by console
r4#
00:47:25: OSPF: Backup seen Event before WAIT timer on FastEthernet0/0
00:47:25: OSPF: DR/BDR election on FastEthernet0/0
00:47:25: OSPF: Elect BDR 1.1.1.1
00:47:25: OSPF: Elect DR 2.2.2.2
00:47:25: DR: 2.2.2.2 (Id) BDR: 1.1.1.1 (Id)
00:47:25: OSPF: Send DBD to 2.2.2.2 on FastEthernet0/0 seq 0x1459 opt 0x00 flag 0x7 len 32
00:47:25: OSPF: Send DBD to 1.1.1.1 on FastEthernet0/0 seq 0x2842 opt 0x00 flag 0x7 len 32
00:47:25: OSPF: Build router LSA for area 0, router ID 4.4.4.4, seq 0x80000009
00:47:29: OSPF: Rcv DBD from 2.2.2.2 on FastEthernet0/0 seq 0x112f opt 0x00 flag 0x7 len 32 mtu 1500 state EXSTART
00:47:29: OSPF: First DBD and we are not SLAVE
00:47:29: OSPF: Rcv DBD from 1.1.1.1 on FastEthernet0/0 seq 0x572 opt 0x00 flag 0x7 len 32 mtu 1500 state EXSTART
00:47:29: OSPF: First DBD and we are not SLAVE
00:47:30: OSPF: Send DBD to 2.2.2.2 on FastEthernet0/0 seq 0x1459 opt 0x00 flag 0x7 len 32
00:47:30: OSPF: Send DBD to 1.1.1.1 on FastEthernet0/0 seq 0x2842 opt 0x00 flag 0x7 len 32
00:47:30: OSPF: Rcv DBD from 2.2.2.2 on FastEthernet0/0 seq 0x1459 opt 0x00 flag 0x2 len 152 mtu 1500 state EXSTART
00:47:30: OSPF: NBR Negotiation Done. We are the MASTER
00:47:30: OSPF: Send DBD to 2.2.2.2 on FastEthernet0/0 seq 0x145a opt 0x00 flag 0x3 len 112
00:47:30: OSPF: Rcv DBD from 1.1.1.1 on FastEthernet0/0 seq 0x2842 opt 0x00 flag 0x2 len 152 mtu 1500 state EXSTART
00:47:30: OSPF: NBR Negotiation Done. We are the MASTER
00:47:30: OSPF: Send DBD to 1.1.1.1 on FastEthernet0/0 seq 0x2843 opt 0x00 flag 0x3 len 112
00:47:30: OSPF: Rcv DBD from 2.2.2.2 on FastEthernet0/0 seq 0x145a opt 0x00 flag 0x0 len 32 mtu 1500 state EXCHANGE
00:47:30: OSPF: Send DBD to 2.2.2.2 on FastEthernet0/0 seq 0x145b opt 0x00 flag 0x1 len 32
00:47:30: OSPF: Rcv DBD from 1.1.1.1 on FastEthernet0/0 seq 0x2843 opt 0x00 flag 0x0 len 32 mtu 1500 state EXCHANGE
00:47:30: OSPF: Send DBD to 1.1.1.1 on FastEthernet0/0 seq 0x2844 opt 0x00 flag 0x1 len 32
00:47:30: OSPF: Rcv DBD from 2.2.2.2 on FastEthernet0/0 seq 0x145b opt 0x00 flag 0x0 len 32 mtu 1500 state EXCHANGE
00:47:30: Exchange Done with 2.2.2.2 on FastEthernet0/0
00:47:30: OSPF: Database request to 2.2.2.2
00:47:30: OSPF: sent LS REQ packet to 192.168.1.2, length 24
00:47:30: OSPF: Rcv DBD from 2.2.2.2 on FastEthernet0/0 seq 0x145b opt 0x00 flag 0x0 len 32 mtu 1500 state LOADING
00:47:30: OSPF: Rcv DBD from 1.1.1.1 on FastEthernet0/0 seq 0x2844 opt 0x00 flag 0x0 len 32 mtu 1500 state EXCHANGE
00:47:30: Exchange Done with 1.1.1.1 on FastEthernet0/0
00:47:30: OSPF: Database request to 1.1.1.1
00:47:30: OSPF: sent LS REQ packet to 192.168.1.1, length 12
00:47:30: Synchronized with with 2.2.2.2 on FastEthernet0/0, state FULL
00:47:30: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/0 from LOADING to FULL, Loading Done
00:47:30: OSPF: Build router LSA for area 0, router ID 4.4.4.4, seq 0x80000009
00:47:30: OSPF: Rcv DBD from 1.1.1.1 on FastEthernet0/0 seq 0x2844 opt 0x00 flag 0x0 len 32 mtu 1500 state LOADING
00:47:30: Synchronized with with 1.1.1.1 on FastEthernet0/0, state FULL
00:47:30: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on FastEthernet0/0 from LOADING to FULL, Loading Done
00:47:30: OSPF: Build router LSA for area 0, router ID 4.4.4.4, seq 0x8000000a
r4#
r4#
r4#show ip ospf ne
r4#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/DR 00:00:34 192.168.1.2 FastEthernet0/0
1.1.1.1 2 FULL/BDR 00:00:35 192.168.1.1 FastEthernet0/0
3.3.3.3 1 2WAY/DROTHER 00:00:38 192.168.1.3 FastEthernet0/0
r4#
通过重新选举的DR和BDR
再次强调一点BR和BDR的选举
【技术要点】
(1)为了避免路由器之间建立完全邻接关系而引起的大量开销,OSPF要求在多路访问
的网络中选举一个 DR,每个路由器都与之建立邻接关系。选举 DR 的同时也选举出一个 BDR,
在 DR 失效的时候,BDR 担负起 DR 的职责,而且所有其它路由器只与 DR 和 BDR 建立邻接关
系;
(2)DR 和BDR 有它们自己的组播地址 224.0.0.6;
(3)DR 和 BDR 的选举是以各个网络为基础的,也就是说 DR 和 BDR 选举是一个路由器
的接口特性,而不是整个路由器的特性;
(4)DR 选举的原则:
① 首要因素是时间,最先启动的路由器被选举成 DR;
② 如果同时启动,或者重新选举,则看接口优先级(范围为 0-255) ,优先级最高的被
选举成 DR,默认情况下,多路访问网络的接口优先级为 1,点到点网络接口优先级为 0,修
改接口优先级的命令是“ ip ospf priority” ,如果接口的优先级被设置为 0,那么该接口将
不参与 DR 选举;
③ 如果前两者相同,最后看路由器 ID,路由器 ID 最高的被选举成 DR;
(5)DR 选举是非抢占的,除非人为地重新选举。重新选举 DR 的方法有两种,一是路
由器重新启动,二是执行“clear ip ospf process”命令。
在 OSPF 邻接关系建立的过程中,接口的状态的变化包括 DOWN、2 Way、EXSTART、
EXCHANGE、Loading和FULL。
转载于:https://blog.51cto.com/crazyguming/411827