Single Area OSPF

 

【实验目的】
了解和掌握OSPF的原理,熟悉OSPF配置步骤。懂得如何配置OSPF router ID,update timers, authentication,了解DR/BDR选举过程。

【基本概念及实验原理】
OSPF数据包的五种类型:
Type 1- Hello
用于建立和维持与邻居的连接信息
Type 2- Database description packet(DBD)
用于描述一个路由器的链路状态数据库的内容
Type 3- Link-state request(LSR)
用于请求一个路由器链路状态数据库的一些特定的条目
Type 4- Link-state update(LSU)
用于把“链路状态更新”(LSAs)传输给其它路由器
Type 5- Link-state acknowledgment (LSAck)
用于确认自己收到了一个从邻居发过来的

 

 

【实验内容】
一、 multi-access网络的OSPF配置
1、配置各台路由器的端口地址,并利用ping命令检查连通性
Router(config)#Interface Ethernet 0
Router(config-if)#ip address 192.168.1.* 255.255.255.*
Router(config-if)#no shutdown
2、配置loopback端口作为OSPF router ID,确保router ID的稳定性。
Router(config)#Interface loopback 0
Router(config-if)#ip address 192.168.*.* 255.255.255.255
3、启动router上OSPF进程并观察
Router(config)#router ospf 1
Router(config-router)#network 192.168.1.0 0.0.0.255 area 0

=====================================================

二、查看OSPF NEIGHBOR

r3#sh ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
192.168.22.22     1   FULL/BDR        00:00:31    192.168.1.2     FastEthernet0/0
192.168.11.11     1   FULL/DROTHER    00:00:32    192.168.1.1     FastEthernet0/0


r3#sh ip ospf neighbor detail
 Neighbor 192.168.22.22, interface address 192.168.1.2
    In the area 0 via interface FastEthernet0/0
    Neighbor priority is 1, State is FULL, 5 state changes
    DR is 192.168.1.3 BDR is 192.168.1.2         //R3被选举为DR,R2为BDR
    Options is 0x00
    Dead timer due in 00:00:31
    Neighbor is up for 00:06:39
    Index 1/1, retransmission queue length 0, number of retransmission 0
    First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
    Last retransmission scan length is 0, maximum is 0
    Last retransmission scan time is 0 msec, maximum is 0 msec
 Neighbor 192.168.11.11, interface address 192.168.1.1
    In the area 0 via interface FastEthernet0/0
    Neighbor priority is 1, State is FULL, 6 state changes
    DR is 192.168.1.3 BDR is 192.168.1.2
    Options is 0x00
    Dead timer due in 00:00:32
    Neighbor is up for 00:06:28
    Index 2/2, retransmission queue length 0, number of retransmission 0
    First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
    Last retransmission scan length is 0, maximum is 2
    Last retransmission scan time is 0 msec, maximum is 0 msec

三、更改timer
R3(config-if)#ip ospf hello-interval 30

R3(config-if)#ip ospf dead-interval 60
由于hello时间间隔有相等的要求,
所以在先改动了一台router参数后可观察到握手不成功。

r3#debug ip ospf event
OSPF events debugging is on
r3#
00:21:05: %OSPF-5-ADJCHG: Process 10, Nbr 192.168.22.22 on FastEthernet0/0 from FULL to DOWN, Neighbor Down: Dead timer expired

00:21:05: OSPF: Neighbor change Event on interface FastEthernet0/0

00:21:05: %OSPF-5-ADJCHG: Process 10, Nbr 192.168.22.22 on FastEthernet0/0 from FULL to Down: Interface down or detached                  //R2与R3断开连接

00:21:05: OSPF: DR/BDR election on FastEthernet0/0

00:21:05: OSPF: Elect BDR 192.168.11.11                 //R1被选为BDR

00:21:05: OSPF: Elect DR 192.168.33.33                    

00:21:05:        DR: 192.168.33.33 (Id)   BDR: 192.168.11.11 (Id)

00:21:05: OSPF: Rcv hello from 192.168.22.22 area 0 from FastEthernet0/0 192.168.1.2

00:21:05: OSPF: Mismatched hello parameters from 192.168.1.2

00:21:05: OSPF: Dead R 40 C 60 Hello R 10 C 30 Mask R 255.255.255.0 C 255.255.255.0

00:21:05: %OSPF-5-ADJCHG: Process 10, Nbr 192.168.11.11 on FastEthernet0/0 from FULL to DOWN, Neighbor Down: Dead timer expired

00:21:05: OSPF: Neighbor change Event on interface FastEthernet0/0

00:21:05: %OSPF-5-ADJCHG: Process 10, Nbr 192.168.11.11 on FastEthernet0/0 from FULL to Down: Interface down or detached                            // //R2与R3断开连接

00:21:05: OSPF: DR/BDR election on FastEthernet0/0

00:21:05: OSPF: Elect BDR 0.0.0.0

00:21:05: OSPF: Elect DR 192.168.33.33

00:21:05:        DR: 192.168.33.33 (Id)   BDR: none

00:21:06: OSPF: Rcv hello from 192.168.11.11 area 0 from FastEthernet0/0 192.168.1.1

00:21:06: OSPF: Mismatched hello parameters from 192.168.1.1    

00:21:06: OSPF: Dead R 40 C 60 Hello R 10 C 30 Mask R 255.255.255.0 C 255.255.255.0

00:21:15: OSPF: Rcv hello from 192.168.22.22 area 0 from FastEthernet0/0 192.168.1.2

00:21:15: OSPF: Mismatched hello parameters from 192.168.1.2
========================================

而R1与R2的连接还在,重新选举DR和BDR

r1#sh ip ospf neighbor detail
 Neighbor 192.168.22.22, interface address 192.168.1.2
    In the area 0 via interface FastEthernet0/0
    Neighbor priority is 1, State is FULL, 6 state changes
    DR is 192.168.1.2 BDR is 192.168.1.1               //r2 为DR,R1为BDR
    Options is 0x00
    Dead timer due in 00:00:34
    Neighbor is up for 00:17:47
    Index 1/1, retransmission queue length 0, number of retransmission 0
    First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
    Last retransmission scan length is 0, maximum is 1
    Last retransmission scan time is 0 msec, maximum is 0 msec

四、改回原DR的interval

此时会再次引发选举,DR恢复原状

R3(config-if)#ip ospf hello-interval 10

R3(config-if)#ip ospf dead-interval 40

r3#debug ip ospf events
OSPF events debugging is on
r3#
……………………

00:32:16: OSPF: End of hello processing

00:32:16: OSPF: Neighbor change Event on interface FastEthernet0/0

00:32:16: OSPF: DR/BDR election on FastEthernet0/0

00:32:16: OSPF: Elect BDR 192.168.11.11

00:32:16: OSPF: Elect DR 192.168.33.33

00:32:16:        DR: 192.168.33.33 (Id)   BDR: 192.168.11.11 (Id)

00:32:26: OSPF: Rcv hello from 192.168.22.22 area 0 from FastEthernet0/0 192.168.1.2

00:32:26: OSPF: End of hello processing

 

重新选举后DR依旧是R3,而BDR却变为了R1而不是ROUTER ID高的R2.这是因为在R3断开之后R2成为DR,R1成为BDR,重新选举时,R2宣告自己为DR,因此不能宣告BDR,而R2的router id要比R3低,而R1宣告自己为BDR。

参见:

1. 在与一个或多个邻居之间的双向通信建立起来之后,(路由器)对每个邻居(发送来)的Hello包中的优先级、DR和BDR域进行检查。列出所有能够参加选举的路由器(也就是说,路由器的优先级高于0并且此路由器的邻居状态至少为“双向”);所有路由器都宣称自己为DR(将它们自己的接口地址置于Hello包的DR域中);而且所有路由器都宣称自己为BDR(将它们自己的接口地址置于Hello包的BDR域中)。进行计算的路由器也要将自身包括在此列表内,除非它被禁止参加选举。
2. 从(以上)备选路由器列表中,创造一个子集,此子集包含所有未宣称为DR的路由器(宣称自己为DR的路由器无法被选举为BDR).
3. 如果此子集中的一或多个邻居将它(们)自身的接口地址置于BDR域中,这些邻居中拥有最高优先级的路由器将被宣告为BDR。如果出现平局(路由器优先级相等),拥有最高Router ID的邻居将被选举出来。
4. 如果此子集中没有任何路由器被宣告为BDR,拥有最高优先级的邻居将被宣告为BDR。如果出现平局,拥有最高Router ID的邻居将被选举出来。
5. 如果一或多个备选路由器将它(们)自身的接口地址置于DR域中,拥有最高优先级的邻居将被宣告为DR。如果出现平局,拥有最高Router ID的邻居将被选举出来。
6. 如果没有任何路由器宣告自己为DR,则新选举出来的BDR将成为DR。
7. 如果进行计算的路由器是新选举出来的DR或者BDR,或者如果它不再是DR或者BDR,重复步骤2到6。

简而言之,当一个OSPF路由器启动并开始搜索邻居时,它先搜寻活动的DR和BDR。如果DR和BDR存在,路由器就接受它们。如果没有BDR,就进行一次选举将拥有最高优先级的路由器选举为BDR。如果多于一台路由器拥有相同的优先级,那么拥有最高路由器ID的路由器将胜出。如果没有活动的DR,BDR将被提升为DR然后再进行一次BDR的选举。


以上译自《Routing TCP/IP Volume I》 Jeff Doyle Cisco Press 1998 / PTP 2003

 

你可能感兴趣的:(职场,休闲,BDR,ospf)