DR和BDR选举​_BDR


1 概念

一个广播域选一个DR和一个BDR

10.1.1.4 priority最高,所以为DR。

10.1.1.3 priority次高,为BDR。

10.1.1.1,10.1.1.2为DR other。

如不手工配置,priority默认为1。

在4台路由器priority都相同的情况下,就要比较router id了。

如果优先级低的设备先做完配置,优先级高的设备后做配置,那优先级低的设备为DR。DR,BDR一旦确认就不会改变,除非设备宕机才会重新选举。

2修改优先级

[AR2]int g0/0/1

[AR2-GigabitEthernet0/0/1]ospf dr-priority 100

[AR2]quit

[AR2]dis ospf peer

OSPF Process 100 with Router ID 2.2.2.2

Neighbors


Area 0.0.0.0 interface 12.1.1.2(GigabitEthernet0/0/1)'s neighbors

Router ID: 1.1.1.1 Address: 12.1.1.1

State: Full Mode:Nbr is Slave Priority: 1

DR: 12.1.1.1 BDR: 12.1.1.2 MTU: 0

Dead timer due in 34 sec

Retrans timer interval: 5

Neighbor is up for 01:04:04

Authentication Sequence: [ 0 ]


Neighbors


Area 0.0.0.0 interface 23.1.1.2(GigabitEthernet0/0/0)'s neighbors

Router ID: 3.3.3.3 Address: 23.1.1.3

State: Full Mode:Nbr is Master Priority: 1

DR: 23.1.1.2 BDR: 23.1.1.3 MTU: 0

Dead timer due in 37 sec

Retrans timer interval: 5

Neighbor is up for 01:02:45

Authentication Sequence: [ 0 ]


3重置OSPF进程

[AR2]quit

<AR2>reset ospf 100 process

[AR1]quit

<AR1>reset ospf 100 process


AR2的端口12.1.1.2成为了DR,AR1的端口12.1.1.1为BDR

[AR2]dis ospf peer

OSPF Process 100 with Router ID 2.2.2.2

Neighbors


Area 0.0.0.0 interface 12.1.1.2(GigabitEthernet0/0/1)'s neighbors

Router ID: 1.1.1.1 Address: 12.1.1.1

State: Full Mode:Nbr is Slave Priority: 1

DR: 12.1.1.2 BDR: 12.1.1.1 MTU: 0

Dead timer due in 31 sec

Retrans timer interval: 5

Neighbor is up for 00:00:14

Authentication Sequence: [ 0 ]


Neighbors


Area 0.0.0.0 interface 23.1.1.2(GigabitEthernet0/0/0)'s neighbors

Router ID: 3.3.3.3 Address: 23.1.1.3

State: Full Mode:Nbr is Master Priority: 1

DR: 23.1.1.3 BDR: 23.1.1.2 MTU: 0

Dead timer due in 39 sec

Retrans timer interval: 4

Neighbor is up for 00:00:55

Authentication Sequence: [ 0 ]

4 cost值计算

DR和BDR选举​_BDR_02


<AR1>dis ospf routing

OSPF Process 100 with Router ID 1.1.1.1

Routing Tables


Routing for Network

Destination Cost Type NextHop AdvRouter Area

1.1.1.1/32 0 Stub 1.1.1.1 1.1.1.1 0.0.0.0

12.1.1.0/24 1 Transit 12.1.1.1 1.1.1.1 0.0.0.0

2.2.2.2/32 1 Stub 12.1.1.2 2.2.2.2 0.0.0.0

3.3.3.3/32 2 Stub 12.1.1.2 3.3.3.3 0.0.0.0

23.1.1.0/24 2 Transit 12.1.1.2 3.3.3.3 0.0.0.0


Total Nets: 5

Intra Area: 5 Inter Area: 0 ASE: 0 NSSA: 0

[AR1]dis ospf int g0/0/0

OSPF Process 100 with Router ID 1.1.1.1

Interfaces


Interface: 12.1.1.1 (GigabitEthernet0/0/0)

Cost: 1 State: BDR Type: Broadcast MTU: 1500

Priority: 1

Designated Router: 12.1.1.2

Backup Designated Router: 12.1.1.1

Timers: Hello 10 , Dead 40 , Poll 120 , Retransmit 5 , Transmit Delay 1


cost值计算为路由传递的方向,所有的cost值累加。

cost=1000000000/BW

bw为带宽,100000000为参考带宽

若带宽为100M=100*1000*1000=1000000000 所以100M带宽的cost值为1。1000M带宽的cost值也为1。这样就容易造成cost计算不准确。

所以建议调整参考带宽,默认为100Mbits/s。建议调整成10Gbits/s。


5调整参考带宽

[AR1]ospf 100

[AR1-ospf-100]bandwidth-reference ?

INTEGER<1-2147483648> The reference bandwidth (Mbits/s)

[AR1-ospf-100]bandwidth-reference 10000


[AR2]ospf 100

[AR2-ospf-100]bandwidth-reference 10000


[AR3]ospf 100

[AR3-ospf-100]bandwidth-reference 10000

参考带宽调整后,相应cost值也变化了

[AR1]dis ospf routing


OSPF Process 100 with Router ID 1.1.1.1

Routing Tables


Routing for Network

Destination Cost Type NextHop AdvRouter Area

1.1.1.1/32 0 Stub 1.1.1.1 1.1.1.1 0.0.0.0

12.1.1.0/24 10 Transit 12.1.1.1 1.1.1.1 0.0.0.0

2.2.2.2/32 10 Stub 12.1.1.2 2.2.2.2 0.0.0.0

3.3.3.3/32 20 Stub 12.1.1.2 3.3.3.3 0.0.0.0

23.1.1.0/24 20 Transit 12.1.1.2 3.3.3.3 0.0.0.0


Total Nets: 5

Intra Area: 5 Inter Area: 0 ASE: 0 NSSA: 0