OSPF DR and BDR Election Explained [with Configuration]
In order to distribute route information within a broadcast domain, OSPF leverages multicast addressing. It use the reserved multicast addresses 224.0.0.5 for IPv4 and FF02::5 for IPv6. OSPF multicast IP packets will not traverse the connected IP routers, only one hop, since the TTL for OSPF packets is defined as 1.
Why do we need OSPF DR and BDR
Contents
Case of no DR-BDR:
If no DR and BDR were elected, all routers in an OSPF segment (broadcast network, ethernet for example) should form OSPF Adjacency with each other, which will lead to full mech OSPF neighborship with a lot of LSA updates exchanged per segment.
Case of DR-BDR elected:
When DR and BDR are elected, Each router forms a Full relationship (/neighbor state) with the Designated Router (DR) and Backup Designated Router (BDR).
Non-DR and Non-BDR (DROther) will only form the 2-Way neighbor state. As a result, they will send/receive Hellos from each other, but no routing updates (LS UPD) are exchanged between them.
DR/BDR Election process
On a Broadcast network (Ethernet segment for example), DR and BDR have to be elected. Two rules are applied in this process:
- router with the highest OSPF priority is elected as the Designated Router (DR).
- If Priorities are equal (by default is 1), a router with the highest router ID will be the DR and the second highest OSPF router ID will become the BDR.
In the election process, the BDR is elected first, then, If no other router declares itself to become DR, then the current BDR becomes DR. If there is a router declaring itself as DR, the BDR will compare its priority/Router ID to the DR attributes.
Example an OSPF debugs of the election process from the next lab:
*Mar 1 00:31:53.807: OSPF: DR/BDR election on Ethernet0/0
*Mar 1 00:31:53.811: OSPF: Elect BDR 2.2.2.2
*Mar 1 00:31:53.811: OSPF: Elect DR 3.3.3.3
*Mar 1 00:31:53.811: DR: 3.3.3.3 (Id) BDR: 2.2.2.2 (Id)
DR and BDR are the central points for exchanging OSPF routing information and updates. Each non-DR or non-BDR router will exchange routing information (LS UPD) only with the DR and BDR, instead of exchanging updates with every router on the network segment.
BDR will take the Designated Router role automatically if the DR goes down.
Exchanging OSPF routing information:
- To send routing information to a DR or BDR the multicast address of 224.0.0.6 is used.
- DR sends routing updates to Non Designated Routers , LSA are sent to the multicast address of 224.0.0.5.
Notes:
- There should be one DR/BDR router on a per-segment basis, not per Area.
- In order to change OSPF Priority on the Interface, use the following command: “ip ospf priority <vlaue>”. 1 is the default OSPF interface priority and the highest priority is 255.
OSPF Priority configuration example:
interface e0/0
ip ospf priority 255
- When you need to prohibit a router from becoming the DR or BDR. You can achieve this by setting the OSPF priority to zero with the “ip ospf priority 0″ under the interface configuration.
interface e0/0
ip ospf priority 0
- OSPF DR election is by a non-preemptive process. So, after changing router-id or priority, we need to enter the following command to reload the OSPF process: ” clear ip ospf process “, you can choose a specific OSPF process like this: ” clear ip ospf process 10“
OSPF DR-BDR Configuration example
Topology:
Routers Configurations:
R1 Configuration:
R1#sh run | sec ospf
ip ospf 10 area 100
router ospf 10
router-id 1.1.1.1
log-adjacency-changes
R1#show run int e0/0
interface Ethernet0/0
ip address 172.16.1.1 255.255.255.248
ip ospf 10 area 100
half-duplex
end
R2 Configuration:
R2#sh run | sec ospf
ip ospf 10 area 100
router ospf 10
router-id 2.2.2.2
log-adjacency-changes
R2#show run int e0/0
interface Ethernet0/0
ip address 172.16.1.2 255.255.255.248
ip ospf 10 area 100
half-duplex
end
R2#
R3 Configuration:
R3#sh run | sec ospf
ip ospf 10 area 100
router ospf 10
router-id 3.3.3.3
log-adjacency-changes
R3#show run int e0/0
interface Ethernet0/0
ip address 172.16.1.3 255.255.255.248
ip ospf 10 area 100
half-duplex
end
R3#
OSPF Neighbors states:
R1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/BDR 00:00:37 172.16.1.2 Ethernet0/0
3.3.3.3 1 FULL/DR 00:00:32 172.16.1.3 Ethernet0/0
R1#
OSPF Adjacency Debugging
Debug OSPF DR-BDR Election on R1:
R1#debug ip ospf adj
R1#clear ip ospf process
*Mar 1 00:31:52.599: OSPF: Rcv DBD from 3.3.3.3 on Ethernet0/0 seq 0x2477 opt 0x52 flag 0x7 len 32 mtu 1500 state 2WAY
*Mar 1 00:31:52.599: OSPF: Nbr state is 2WAY
*Mar 1 00:31:53.807: OSPF: Backup seen Event before WAIT timer on Ethernet0/0
*Mar 1 00:31:53.807: OSPF: DR/BDR election on Ethernet0/0
*Mar 1 00:31:53.811: OSPF: Elect BDR 2.2.2.2
*Mar 1 00:31:53.811: OSPF: Elect DR 3.3.3.3
*Mar 1 00:31:53.811: DR: 3.3.3.3 (Id) BDR: 2.2.2.2 (Id)
*Mar 1 00:31:53.811: OSPF: Send DBD to 2.2.2.2 on Ethernet0/0 seq 0x1286 opt 0x52 flag 0x7 len 32
*Mar 1 00:31:53.815: OSPF: Send DBD to 3.3.3.3 on Ethernet0/0 seq 0xAB opt 0x52 flag 0x7 len 32
*Mar 1 00:31:53.815: OSPF: Rcv DBD from 2.2.2.2 on Ethernet0/0 seq 0xD72 opt 0x52 flag 0x7 len 32 mtu 1500 state EXSTART
*Mar 1 00:31:53.815: OSPF: NBR Negotiation Done. We are the SLAVE
*Mar 1 00:31:53.819: OSPF: Send DBD to 2.2.2.2 on Ethernet0/0 seq 0xD72 opt 0x52 flag 0x2 len 52
*Mar 1 00:31:53.867: OSPF: Rcv DBD from 2.2.2.2 on Ethernet0/0 seq 0xD73 opt 0x52 flag 0x3 len 52 mtu 1500 state EXCHANGE
*Mar 1 00:31:53.867: OSPF: Send DBD to 2.2.2.2 on Ethernet0/0 seq 0xD73 opt 0x52 flag 0x0 len 32
*Mar 1 00:31:53.915: OSPF: Rcv DBD from 2.2.2.2 on Ethernet0/0 seq 0xD74 opt 0x52 flag 0x1 len 32 mtu 1500 state EXCHANGE
*Mar 1 00:31:53.915: OSPF: Exchange Done with 2.2.2.2 on Ethernet0/0
*Mar 1 00:31:53.919: OSPF: Send LS REQ to 2.2.2.2 length 12 LSA count 1
*Mar 1 00:31:53.919: OSPF: Send DBD to 2.2.2.2 on Ethernet0/0 seq 0xD74 opt 0x52 flag 0x0 len 32
*Mar 1 00:31:53.923: OSPF: Rcv LS REQ from 2.2.2.2 on Ethernet0/0 length 36 LSA count 1
*Mar 1 00:31:53.923: OSPF: Send UPD to 172.16.1.2 on Ethernet0/0 length 40 LSA count 1
*Mar 1 00:31:53.963: OSPF: Rcv LS UPD from 2.2.2.2 on Ethernet0/0 length 64 LSA count 1
*Mar 1 00:31:53.963: OSPF: Synchronized with 2.2.2.2 on Ethernet0/0, state FULL
Debug OSPF DR-BDR Election on R2:
R2#debug ip ospf adj
*Mar 1 00:31:57.391: OSPF: Neighbor change Event on interface Ethernet0/0
*Mar 1 00:31:57.391: OSPF: DR/BDR election on Ethernet0/0
*Mar 1 00:31:57.391: OSPF: Elect BDR 2.2.2.2
*Mar 1 00:31:57.395: OSPF: Elect DR 3.3.3.3
*Mar 1 00:31:57.395: DR: 3.3.3.3 (Id) BDR: 2.2.2.2 (Id)
*Mar 1 00:31:57.579: OSPF: Rcv LS UPD from 3.3.3.3 on Ethernet0/0 length 64 LSA count 1
*Mar 1 00:31:58.095: OSPF: Rcv LS UPD from 1.1.1.1 on Ethernet0/0 length 64 LSA count 1
*Mar 1 00:31:58.103: OSPF: Rcv LS UPD from 3.3.3.3 on Ethernet0/0 length 64 LSA count 1
R2#
OSPF DR-BDR Election on R3:
R3#debug ip ospf adj
*Mar 1 00:31:54.495: OSPF: Build network LSA for Ethernet0/0, router ID 3.3.3.3
*Mar 1 00:31:57.495: OSPF: Neighbor change Event on interface Ethernet0/0
*Mar 1 00:31:57.495: OSPF: DR/BDR election on Ethernet0/0
*Mar 1 00:31:57.495: OSPF: Elect BDR 2.2.2.2
*Mar 1 00:31:57.499: OSPF: Elect DR 3.3.3.3
*Mar 1 00:31:57.499: DR: 3.3.3.3 (Id) BDR: 2.2.2.2 (Id)
*Mar 1 00:31:57.499: OSPF: Neighbor change Event on interface Ethernet0/0
*Mar 1 00:31:57.499: OSPF: DR/BDR election on Ethernet0/0
*Mar 1 00:31:57.499: OSPF: Elect BDR 2.2.2.2
*Mar 1 00:31:57.503: OSPF: Elect DR 3.3.3.3
*Mar 1 00:31:57.503: DR: 3.3.3.3 (Id) BDR: 2.2.2.2 (Id)
*Mar 1 00:31:57.563: OSPF: Send DBD to 1.1.1.1 on Ethernet0/0 seq 0x2477 opt 0x52 flag 0x7 len 32
*Mar 1 00:31:57.563: OSPF: Retransmitting DBD to 1.1.1.1 on Ethernet0/0 [6]