【实验目的】
在 OSPF 的理论中我们曾介绍到,在 NBMA 和广播的网络当中,为了避免 OSPF 邻居
过多而提出了 DR 的概念,为了在 DR 失败的时候,能迅速的得到备份,而提出了 BDR 这
一概念,本 实验来验证DR/BDR 的选举及DR/BDR 的相关原则及特性。
 
【实验拓扑及所用软件】
 
 

 

 

 

 

   实验拓扑如上图,所用的软件是H3C的模拟器,在H3C论坛上有下载,有兴趣的朋友可以到论坛上去找。在本篇的结尾会把所有配置给出来,欢迎大家一起交流。

【配置步骤】

 

 

1、DR的选举

 

因为默认都是P-TO-P的网络类型,不进行DR\BDR的选举

 

现将R5、R1、R2互联的接口类型更改成broadcast的类型

 

如下是R1更改的

interface Serial0/6/0

 link-protocol ppp

 ip address 3.3.3.1 255.255.255.252

 ospf network-type broadcast

#

interface Serial0/6/3

 link-protocol ppp

 ip address 2.2.2.1 255.255.255.252

 ospf network-type broadcast

 

2、将R5、R1、R2互联的接口类型更改成broadcast的类型后查看

[R1]dis ospf interface 

 

         OSPF Process 1 with Router ID 10.1.1.2

                 Interfaces 

 

 Area: 0.0.0.0        

 IP Address      Type      State    Cost  Pri   DR              BDR 

 3.3.3.1         Broadcast BDR      1562  1     3.3.3.2         3.3.3.1

 

 Area: 0.0.0.1        

 IP Address      Type      State    Cost  Pri   DR              BDR 

 2.2.2.1         Broadcast DR       1562  1     2.2.2.1         2.2.2.2

 

如上显示可知 在3.3.3.0/30网段 DR是3.3.3.2      BDR是3.3.3.1  也就是说DR是R2  BDR是R1

             在2.2.2.0/30网段 DR是2.2.2.1      BDR是 2.2.2.2   也就是说DR是R1  BDR是R5

为什么呢?

 

 

DR选举原则基本 2条:1、只有优先级大于 0的路由器才能参与竞选;2、选举时先

比较优先级,大者优先;若优先级相等,则比较 Router id,也是大者优先。

 

有了上面两条规则就很好解释了:R2 Router id> R1 Router id> R5 Router id 并没有用优先级来作选举,因为优先级都为1。

 

3、

 

现在我们把R5与R1互连的接口优先级作更改如下:

 

[R5-Serial0/6/3]ospf dr-priority 100

[R5-Serial0/6/3]qu

[R5]dis ospf int

[R5]dis ospf interface 

 

         OSPF Process 1 with Router ID 10.1.1.1

                 Interfaces 

 

 Area: 0.0.0.1        

 IP Address      Type      State    Cost  Pri   DR              BDR 

 2.2.2.2         Broadcast BDR      1562  100   2.2.2.1         2.2.2.2

 1.1.1.1         PTP       Loopback 1     1     0.0.0.0         0.0.0.0

 

 

 

发现 R5 的 S0/6/3的接口优先级由原来的 1确实改变成了现在的 100,但 DR/BDR

的状态依旧,没有发生任何变化;这是因为 DR和 BDR遵循一个原则:“ 。

既然是稳定压倒一切,如果网络故障,那 DR/BDR 状态应该变化了吧,下面我们把 DR 对

应的接口,也就是 R1 的 S0/6/3接口给人为关闭重启一下:

 

 [R1-Serial0/6/3]shut

[R1-Serial0/6/3]

%Jan 17 14:59:53:985 2013 R1 IFNET/4/UPDOWN:

 Line protocol on the interface Serial0/6/3 is DOWN 

%Jan 17 14:59:53:985 2013 R1 IFNET/4/UPDOWN:

 Protocol PPP IPCP on the interface Serial0/6/3 is DOWN 

%Jan 17 14:59:54:00 2013 R1 RM/3/RMLOG:OSPF-NBRCHANGE: Process 1, Neighbor 2.2.2.2(Serial0/6/3) from Full to Down

[R1-Serial0/6/3]

[R1-Serial0/6/3]undo shut

[R1-Serial0/6/3]

[R1-Serial0/6/3]

[R1-Serial0/6/3]

%Jan 17 14:59:58:297 2013 R1 IFNET/4/UPDOWN:

 Line protocol on the interface Serial0/6/3 is UP 

%Jan 17 14:59:58:297 2013 R1 IFNET/4/UPDOWN:

 Protocol PPP IPCP on the interface Serial0/6/3 is UP 

[R1-Serial0/6/3]

[R1-Serial0/6/3]dis ospf interface 

%Jan 17 15:00:32:516 2013 R1 RM/3/RMLOG:OSPF-NBRCHANGE: Process 1, Neighbor 2.2.2.2(Serial0/6/3) from Loading to Full

 

         OSPF Process 1 with Router ID 10.1.1.2

                 Interfaces 

 

 Area: 0.0.0.0        

 IP Address      Type      State    Cost  Pri   DR              BDR 

 3.3.3.1         Broadcast BDR      1562  1     3.3.3.2         3.3.3.1

 

 Area: 0.0.0.1        

 IP Address      Type      State    Cost  Pri   DR              BDR 

 2.2.2.1         Broadcast BDR      1562  1     2.2.2.2         2.2.2.1     DR和BDR的位置已经颠倒

 

由此发现,这招起作用了,DR和BDR的状态发生了改变,DR由2.2.2.1变成了2.2.2.2,

看来只有在拓扑发生变化的时候,DR和 BDR的状态才会发生变化。 

 

 

 

4、

接下来,我们来尝试一下,如果将一个接口的优先级改为“0”会是什么样子?我们首

先将 R1的 S0/6/0接口优先级改为“0”: 

 

配置前

 

[R1]dis ospf interface 

 

         OSPF Process 1 with Router ID 10.1.1.2

                 Interfaces 

 

 Area: 0.0.0.0        

 IP Address      Type      State    Cost  Pri   DR              BDR 

 3.3.3.1         Broadcast BDR      1562  1     3.3.3.2         3.3.3.1

 

 Area: 0.0.0.1        

 IP Address      Type      State    Cost  Pri   DR              BDR 

 2.2.2.1         Broadcast BDR      1562  1     2.2.2.2         2.2.2.1

 

 

[R1]

[R1]

[R1]int s0/6/0

[R1-Serial0/6/0]dis th

#

interface Serial0/6/0

 link-protocol ppp

 ip address 3.3.3.1 255.255.255.252 

 ospf network-type broadcast

#

return

[R1-Serial0/6/0]ospf dr

[R1-Serial0/6/0]ospf dr-priority 0

%Jan 17 15:04:41:938 2013 R1 RM/3/RMLOG:OSPF-NBRCHANGE: Process 1, Neighbor 3.3.3.2(Serial0/6/0) from Full to Down

[R1-Serial0/6/0]

[R1-Serial0/6/0]

[R1-Serial0/6/0]

%Jan 17 15:04:49:00 2013 R1 RM/3/RMLOG:OSPF-NBRCHANGE: Process 1, Neighbor 3.3.3.2(Serial0/6/0) from Loading to Full

[R1-Serial0/6/0]dis ospf int

[R1-Serial0/6/0]dis ospf interface 

 

 

配置后有如下

 

         OSPF Process 1 with Router ID 10.1.1.2

                 Interfaces 

 

 Area: 0.0.0.0        

 IP Address      Type      State    Cost  Pri   DR              BDR 

 3.3.3.1         Broadcast DROther  1562  0     3.3.3.2         0.0.0.0  注意此处!!!

 

 Area: 0.0.0.1        

 IP Address      Type      State    Cost  Pri   DR              BDR 

 2.2.2.1         Broadcast BDR      1562  1     2.2.2.2         2.2.2.1

 

 

[R1-Serial0/6/0]dis ospf peer

 

                  OSPF Process 1 with Router ID 10.1.1.2

                        Neighbor Brief Information

 

 Area: 0.0.0.0        

 Router ID       Address         Pri Dead-Time Interface       State

 10.1.1.3        3.3.3.2         1   29        S0/6/0          Full/DR

 

 Area: 0.0.0.1        

 Router ID       Address         Pri Dead-Time Interface       State

 10.1.1.1        2.2.2.2         100 35        S0/6/3          Full/DR

 

由上面的信息可以看出,R1 的 S0/6/0接口优先级改为“0”后,失去了竞选资格,

变为了 DROther,这时 3.3.3.0/30 网段只有 DR,而没有 BDR;但 OSPF 工作是正常的,

R2和 R2之间仍然能建立邻居关系,而且达到了“full”状态。看来在广播类型

的网络中,只要有 DR即可工作。 

 

5、

如果将 R2 的 S0/6/0 口的优先级也改为“0”的话,不知道是何后果,我们通过实

验来观察一下: 

 

[R2-Serial0/6/0]ospf dr-priority 0

%Jan 17 15:08:30:516 2013 R2 RM/3/RMLOG:OSPF-NBRCHANGE: Process 1, Neighbor 3.3.3.1(Serial0/6/0) from Full to Down

[R2-Serial0/6/0]

[R2-Serial0/6/0]

[R2-Serial0/6/0]

[R2-Serial0/6/0]

[R2-Serial0/6/0]

[R2-Serial0/6/0]

[R2-Serial0/6/0]

[R2-Serial0/6/0]

[R2-Serial0/6/0]

[R2-Serial0/6/0]dis ospf int

[R2-Serial0/6/0]dis ospf interface 

 

         OSPF Process 1 with Router ID 10.1.1.3

                 Interfaces 

 

 Area: 0.0.0.0        

 IP Address      Type      State    Cost  Pri   DR              BDR 

 3.3.3.2         Broadcast DROther  1562  0     0.0.0.0         0.0.0.0

 

 Area: 0.0.0.2        

 IP Address      Type      State    Cost  Pri   DR              BDR 

 4.4.4.1         PTP       P-2-P    1562  1     0.0.0.0         0.0.0.0

 

 

[R2-Serial0/6/0]dis ospf peer

 

                  OSPF Process 1 with Router ID 10.1.1.3

                        Neighbor Brief Information

 

 Area: 0.0.0.0        

 Router ID       Address         Pri Dead-Time Interface       State

 10.1.1.2        3.3.3.1         0   30        S0/6/0          2-Way/ -

 

 Area: 0.0.0.2        

 Router ID       Address         Pri Dead-Time Interface       State

 10.1.1.4        4.4.4.2         1   31        S0/6/1          Full/ -

[R2-Serial0/6/0]

[R2-Serial0/6/0]dis ip ro

Routing Tables: Public

        Destinations : 10       Routes : 10

 

Destination/Mask    Proto  Pre  Cost         NextHop         Interface

 

3.3.3.0/30          Direct 0    0            3.3.3.2         S0/6/0

3.3.3.1/32          Direct 0    0            3.3.3.1         S0/6/0

3.3.3.2/32          Direct 0    0            127.0.0.1       InLoop0

4.4.4.0/30          Direct 0    0            4.4.4.1         S0/6/1

4.4.4.1/32          Direct 0    0            127.0.0.1       InLoop0

4.4.4.2/32          Direct 0    0            4.4.4.2         S0/6/1

5.5.5.1/32          OSPF   10   1562         4.4.4.2         S0/6/1

10.1.1.3/32         Direct 0    0            127.0.0.1       InLoop0

127.0.0.0/8         Direct 0    0            127.0.0.1       InLoop0

127.0.0.1/32        Direct 0    0            127.0.0.1       InLoop0

 

[R2-Serial0/6/0]

 

 

 

 

从上面的信息中,我们发现:将 R2的 S0/6/0接口的优先级改为“0”后,RouterB

也变成了 DROther,而 2个 DROther 之间建立邻居关系一直会停留在 2-way状态,在这个

状态不能直接交流信息,所以路由学习也不正常;看来在 OSPF 网络中,如果是广播类型

的网络,对于一个网段而言:必须有一个接口的优先级大于 0。 

 

 

【注意事项】 DR和 BDR的选举原则: 

1、广播网络或NBMA 类型的网络需要选举指定路由器 DR(Designated Router)和备份指

定路由器 BDR(Backup Designated Router)。 

2、路由器接口的优先级 Priority 将影响接口在选举 DR 时所具有的资格。优先级为 0 的路

由器不会被选举为 DR或 BDR。 

3、DR 由条Priority 大于 0 的路由器都可作为“候选者”,选票

就是 Hello 报文,OSPF 路由器将自己选出的 DR 写入 Hello 报文中,发给网段上的其它路

由器。当同一网段的两台路由器都宣布自己是 DR时,Priority高的胜出。如果 Priority相等,

则 Router ID大的胜出。 

4、如果 DR失效,则网络中的路由器必须重新选举 DR,并与新的 DR同步,为了缩短这个

过程,OSPF 提出了 BDR(Backup Designated Router,备份指定路由器)的概念,与 DR

同时被选举出来。BDR 也与本 DR失效

后,BDR立即成为 DR,由于不需要重新选举,并且邻接关系已经建立,所以这个过程可以

很快完成。这时,还需要选举出一个新的 BDR,这时不会影响路由的计算。 

   DR和 BDR的指导思想: 

选举制:DR是各路由器选出来的,而非人工指定的,虽然管理员可以通过配置 priority干预

选举过程。 

终身制:DR一旦当选,除非路由器故障,否则不会更换,即使后来的路由器 priority更高 

世袭制:DR选出的同时也选出 BDR来,DR故障后,由 BDR接替 DR成为新的 DR。 

   DR和 BDR的注意事项: 

1、只有在广播和 NBMA的链路上才会选举 DR,在 PTP 和PTMP 的链路上不会选举 DR。 

2、DR是针对一个网段内的设备选举的,对于一台路由器来说,可能它在某个接口上是 DR 

3、在其它接口上是 BDR、DROther,或者因为是 PTP 的链路而不参加 DR的选举。 

4、在广播的网络上必须存在 DR才能够正常工作,但 BDR不是必需的。 

5、一个网段中即使只有一台路由器,也要选举 DR。 

6、由于“终身制”的原因,网段中的 DR 不一定是 priority 最高的,但通常是“来的早”的路由

器。 

【配置文件】

 

R1:

<R1>dis cu

#

 version 5.20, Alpha 1011

#

 sysname R1

#

 password-control login-attempt 3 exceed lock-time 120

#

 undo voice vlan mac-address 00e0-bb00-0000

#

 ipsec cpu-backup enable

#

 undo cryptoengine enable

#

 domain default enable system

#

vlan 1

#

domain system

 access-limit disable

 state active

 idle-cut disable

 self-service-url disable

#

interface Serial0/6/0

 link-protocol ppp

 ip address 3.3.3.1 255.255.255.252

 ospf network-type broadcast

 ospf dr-priority 0

#

interface Serial0/6/1

 link-protocol ppp

#

interface Serial0/6/2

 link-protocol ppp

#

interface Serial0/6/3

 link-protocol ppp

 ip address 2.2.2.1 255.255.255.252

 ospf network-type broadcast

#

interface NULL0

#

interface LoopBack0

 ip address 10.1.1.2 255.255.255.255

#

interface LoopBack1

#               

interface Ethernet0/4/0

 port link-mode bridge

#

interface Ethernet0/4/1

 port link-mode bridge

#

interface Ethernet0/4/2

 port link-mode bridge

#

interface Ethernet0/4/3

 port link-mode bridge

#

interface Ethernet0/4/4

 port link-mode bridge

#

interface Ethernet0/4/5

 port link-mode bridge

#

interface Ethernet0/4/6

 port link-mode bridge

#

interface Ethernet0/4/7

 port link-mode bridge

#

ospf 1 router-id 10.1.1.2

 area 0.0.0.0

  network 3.3.3.0 0.0.0.3

 area 0.0.0.1

  network 2.2.2.0 0.0.0.3

#

 load xml-configuration

#

user-interface con 0

user-interface vty 0 4

#

return

 
R2:
<R2>dis cu
#
 version 5.20, Alpha 1011
#
 sysname R2
#
 password-control login-attempt 3 exceed lock-time 120
#
 undo voice vlan mac-address 00e0-bb00-0000
#
 ipsec cpu-backup enable
#
 undo cryptoengine enable
#
 domain default enable system
#
vlan 1
#
domain system
 access-limit disable
 state active
 idle-cut disable
 self-service-url disable
#
interface Serial0/6/0
 link-protocol ppp
 ip address 3.3.3.2 255.255.255.252
 ospf network-type broadcast
 ospf dr-priority 0
#
interface Serial0/6/1
 link-protocol ppp
 ip address 4.4.4.1 255.255.255.252
#
interface Serial0/6/2
 link-protocol ppp
#
interface Serial0/6/3
 link-protocol ppp
#
interface NULL0
#
interface LoopBack0
 ip address 10.1.1.3 255.255.255.255
#
interface Ethernet0/4/0
 port link-mode bridge
#               
interface Ethernet0/4/1
 port link-mode bridge
#
interface Ethernet0/4/2
 port link-mode bridge
#
interface Ethernet0/4/3
 port link-mode bridge
#
interface Ethernet0/4/4
 port link-mode bridge
#
interface Ethernet0/4/5
 port link-mode bridge
#
interface Ethernet0/4/6
 port link-mode bridge
#
interface Ethernet0/4/7
 port link-mode bridge
#
ospf 1 router-id 10.1.1.3
 area 0.0.0.0   
  network 3.3.3.0 0.0.0.3
 area 0.0.0.2
  network 4.4.4.0 0.0.0.3
#
 load xml-configuration
#
user-interface con 0
user-interface vty 0 4
#
return
 
R5:
 
<R5>dis cu
#
 version 5.20, Alpha 1011
#
 sysname R5
#
 password-control login-attempt 3 exceed lock-time 120
#
 undo voice vlan mac-address 00e0-bb00-0000
#
 ipsec cpu-backup enable
#
 undo cryptoengine enable
#
 domain default enable system
#
vlan 1
#
domain system
 access-limit disable
 state active
 idle-cut disable
 self-service-url disable
#
interface Serial0/6/0
 link-protocol ppp
#
interface Serial0/6/1
 link-protocol ppp
#
interface Serial0/6/2
 link-protocol ppp
#
interface Serial0/6/3
 link-protocol ppp
 ip address 2.2.2.2 255.255.255.252
 ospf network-type broadcast
 ospf dr-priority 100
#
interface NULL0
#
interface LoopBack0
 ip address 10.1.1.1 255.255.255.255
#
interface LoopBack1
 ip address 1.1.1.1 255.255.255.255
#
interface Ethernet0/4/0
 port link-mode bridge
#
interface Ethernet0/4/1
 port link-mode bridge
#
interface Ethernet0/4/2
 port link-mode bridge
#
interface Ethernet0/4/3
 port link-mode bridge
#
interface Ethernet0/4/4
 port link-mode bridge
#
interface Ethernet0/4/5
 port link-mode bridge
#
interface Ethernet0/4/6
 port link-mode bridge
#
interface Ethernet0/4/7
 port link-mode bridge
#               
interface Ethernet0/4/8
 port link-mode bridge
#
interface Ethernet0/4/9
 port link-mode bridge
#
interface Ethernet0/4/10
 port link-mode bridge
#
interface Ethernet0/4/11
 port link-mode bridge
#
interface Ethernet0/4/12
 port link-mode bridge
#
interface Ethernet0/4/13
 port link-mode bridge
#
interface Ethernet0/4/14
 port link-mode bridge
#
interface Ethernet0/4/15
 port link-mode bridge
#
interface Ethernet0/4/16
 port link-mode bridge
#
interface Ethernet0/4/17
 port link-mode bridge
#
interface Ethernet0/4/18
 port link-mode bridge
#
interface Ethernet0/4/19
 port link-mode bridge
#
interface Ethernet0/4/20
 port link-mode bridge
#
interface Ethernet0/4/21
 port link-mode bridge
#
interface Ethernet0/4/22
 port link-mode bridge
#
interface Ethernet0/4/23
 port link-mode bridge
#
ospf 1 router-id 10.1.1.1
 area 0.0.0.1
  network 2.2.2.0 0.0.0.3
  network 1.1.1.1 0.0.0.0
#
 load xml-configuration
#
user-interface con 0
user-interface vty 0 4
#
return