Which step does an OSPF enabled router take immediately after establishing an adjacency with another router?

Router ID

Before learning the DR/BDR election process, you need to know the router ID. A router ID is a 32-bit integer, which uniquely identifies an OSPF router in an AS. Each OSPF router has a router ID. A router ID is in the same format as an IP address. To ensure OSPF stability in actual network deployment, it is recommended that the IP address of a loopback interface on a router be used as the router ID of this router.

A router ID can be manually configured or automatically selected by a router.

If no router ID is manually configured for a router, the router automatically selects an interface IP address as its router ID. The router ID selection rules are as follows:

  1. The router preferentially selects the largest IP address among loopback interface addresses as the router ID.

  2. If no loopback interface is configured, the router selects the largest IP address among interface addresses as the router ID.

A switch can obtain a router ID again only after a router ID is reconfigured for the switch or an OSPF router ID is reconfigured and the OSPF process restarts.

Reason for DR/BDR Election

On broadcast and non-broadcast multiple access (NBMA) networks, any two routers need to exchange routing information. On the network in Figure 1, there are n routers that need to establish n x (n - 1)/2 adjacencies. A route change on any router is transmitted to the other routers, which wastes bandwidth resources.

To solve this problem, the concept of DR is defined in OSPF. After a DR is elected, all the other routers send routing information only to the DR, and the DR broadcasts LSAs.

To prevent service interruption caused by DR re-election when the DR fails, a BDR is also elected during DR election. The routers excluding DR and BDR are called DR others. The DR others do not establish adjacencies or exchange any routing information with each other. This reduces the number of adjacencies established between routers on broadcast and NBMA networks.

Figure 5-8  DR/BDR Election

DR/BDR Election Principles

To ensure stable DR/BDR election on broadcast and NBMA networks, OSPF defines three election principles: election, non-preemption, and inheritance.

Election Principle

The DR and BDR are not designated manually, but are elected by all routers on the local network segment. In Figure 2, DR priorities of router interfaces determine whether the interfaces are qualified for DR/BDR election. Routers with DR priorities larger than 0 on the local network segment can be considered as candidates. The ballots in this election are Hello packets. Each router adds elected DR information to a Hello packet and sends the packet to other routers on the network segment. When two routers on the same network segment declare that they are the DR, the router with a higher DR priority is elected as the DR. If the two switch interfaces have the same DR priority, the switch interface with a larger router ID is elected as a DR. The router whose priority is 0 cannot be elected as a DR or a BDR.

Figure 5-9  Election principle

Non-preemption Principle

A router newly added to a network segment does not attempt in election and checks whether a DR exists on the network segment. In Figure 3, a DR exists on the network segment. Even if the DR priority of the newly added router is higher than that of the DR, the newly added router does not declare itself as the DR, and acknowledges the existing DR. Routers on a network segment only establish adjacencies with the DR and BDR. If the DR changes frequently, all routers on the network segment need to establish adjacencies with the new DR and BDR accordingly. As a result, a large number of OSPF packets are transmitted on the network segment within a short period of time, reducing the available bandwidth. The non-preemption principle improves network stability and saves the available network bandwidth. On a broadcast or NBMA network, the two routers that are qualified for DR election and start first become the DR and BDR.

Figure 5-10  Non-preemption principle

Inheritance Principle

If the DR on a network segment fails, the BDR is elected as the DR, and the other routers compete to become the new BDR, as shown in Figure 4. This principle ensures the DR stability and prevents frequent DR elections. If the DR has a BDR, the BDR becomes the new DR when the DR fails. Because LSDBs of the DR and BDR are fully synchronized, the BDR immediately becomes the new DR when the DR fails and performs duties of the DR. Because adjacencies have been established, the time from role change to service switching is short. In addition, when the BDR becomes the new DR, a new BDR will be elected. Although the election process takes a relatively long time, route calculation is not affected.

Figure 5-11  Inheritance principle

DR/BDR Election Process

The DR/BDR election process on a broadcast or NBMA network is as follows:

  1. After an interface goes Up, it sends a Hello packet and enters the Waiting state. In the Waiting state, a wait timer is triggered. The wait timer value is the same as the dead timer value. The default wait timer value is 40 seconds and cannot be changed. For details about OSPF interface status, see OSPF Interface State Machine.

  2. Before the wait timer is triggered, sent Hello packets do not contain DR or BDR information. In the Waiting state, if a received Hello packet contains DR and BDR information, the interface directly acknowledges the DR and BDR on the network, and does not trigger election. The interface directly exits the Waiting state and starts neighbor synchronization.

  3. Assume that a DR and a BDR exist on the network. A router newly connected to the network acknowledges the existing DR and BDR regardless of how large its router ID or DR priority is.

  4. If the DR fails and goes down, the BDR takes over the role of the DR and the other routers whose priority is greater than 0 compete to become the new BDR.

  5. DR election rules are used to elect a DR only when routers with different router IDs or configured with different DR priorities are started at the same time. The election rules are that the device with the highest DR priority is elected as DR and the device with the second highest DR priority as BDR. A router with a DR priority of 0 can be a DR other only. If routers have the same DR priority, the router with the greatest router ID is elected as the DR, the router with the second greatest router ID becomes the BDR, and other routers are DR others.

Verifying the DR/BDR Election Process

Five routers establish a broadcast network. R5 works as a Layer 2 device, and R1 to R4 work as routers. R1 to R4 are in OSPF area 0. The IP addresses and router IDs of the routers are shown in Figure 5.

Figure 5-12  DR/BDR election networking

DR and BDR Are Properly Elected on the Network

Assume that interfaces on R1 to R4 are configured. Only OSPF configurations are provided here.

  • Configuration of R1

    #
    ospf 1 Router ID 10.1.1.1 
     area 0.0.0.0 
      network 192.168.1.0 0.0.0.255 
    #
  • Configuration of R2

    #
    ospf 1 Router ID 10.2.2.2
     area 0.0.0.0 
      network 192.168.1.0 0.0.0.255 
    #
  • Configuration of R3

    #
    ospf 1 Router ID 10.3.3.3 
     area 0.0.0.0 
      network 192.168.1.0 0.0.0.255 
    #
  • Configuration of R4

    #
    ospf 1 Router ID 10.4.4.4
     area 0.0.0.0 
      network 192.168.1.0 0.0.0.255 
    #

After the configurations are complete and the network is stable, check the DR/BDR election status.

# Check OSPF neighbor information on R1. The following command output shows that DR/BDR election has been completed. R1 is the DR, R2 is the BDR, and R3 and R4 are DR others. The reason why R1 and R2 are elected as the DR and BDR respectively is directly related to their startup sequence. In this example, R1, R2, R3, and R4 are started in sequence. Therefore, R1 and R2 complete initialization first and become the DR and BDR, respectively.

<R1> display ospf peer

         OSPF Process 1 with Router ID 10.1.1.1
                 Neighbors

 Area 0.0.0.0 interface 192.168.1.1(GigabitEthernet0/0/1)'s neighbors
 Router ID: 10.2.2.2         Address: 192.168.1.2
   State: Full  Mode:Nbr is Master  Priority: 1
   DR: 192.168.1.1  BDR: 192.168.1.2   MTU: 0
   Dead timer due in 38  sec
   Retrans timer interval: 5
   Neighbor is up for 00:22:16
   Authentication Sequence: [ 0 ]

 Router ID: 10.3.3.3         Address: 192.168.1.3
   State: Full  Mode:Nbr is Master   Priority: 1
   DR: 192.168.1.1  BDR: 192.168.1.2   MTU: 0
   Dead timer due in 35  sec
   Retrans timer interval: 5
   Neighbor is up for 00:21:30
   Authentication Sequence: [ 0 ]

 Router ID: 10.4.4.4         Address: 192.168.1.4
   State: Full  Mode:Nbr is Master   Priority: 1
   DR: 192.168.1.1  BDR: 192.168.1.2   MTU: 0
   Dead timer due in 33  sec
   Retrans timer interval: 5
   Neighbor is up for 00:20:24
   Authentication Sequence: [ 0 ]

# Check brief OSPF neighbor information on R1, R2, R3, and R4. The following command outputs show that the states of neighbor relationships between R1 and the other three routers and those between R2 and the other three routers are Full, and the state of the neighbor relationship between R3 and R4 is 2-Way. The states indicate that the DR and BDR establish adjacencies with other routers, and DR others only establish neighbor relationships. For details about OSPF neighbor status, see OSPF Neighbor State Machine.

<R1> display ospf 1 peer brief

         OSPF Process 1 with Router ID 10.1.1.1
                   Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id         Interface                  Neighbor id      State
 0.0.0.0         GigabitEthernet0/0/1       10.2.2.2         Full
 0.0.0.0         GigabitEthernet0/0/1       10.3.3.3         Full
 0.0.0.0         GigabitEthernet0/0/1       10.4.4.4         Full
 ----------------------------------------------------------------------------
 Total Peer(s):     3
<R2> display ospf 1 peer brief

         OSPF Process 1 with Router ID 10.2.2.2
                   Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id         Interface                  Neighbor id      State
 0.0.0.0         GigabitEthernet0/0/1       10.1.1.1         Full
 0.0.0.0         GigabitEthernet0/0/1       10.3.3.3         Full
 0.0.0.0         GigabitEthernet0/0/1       10.4.4.4         Full
 ----------------------------------------------------------------------------
 Total Peer(s):     3
<R3> display ospf 1 peer brief

         OSPF Process 1 with Router ID 10.3.3.3
                   Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id         Interface                  Neighbor id      State
 0.0.0.0         GigabitEthernet0/0/1       10.1.1.1         Full
 0.0.0.0         GigabitEthernet0/0/1       10.2.2.2         Full
 0.0.0.0         GigabitEthernet0/0/1       10.4.4.4         2-Way
 ----------------------------------------------------------------------------
 Total Peer(s):     3
<R4> display ospf 1 peer brief

         OSPF Process 1 with Router ID 10.4.4.4
                   Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id         Interface                  Neighbor id      State
 0.0.0.0         GigabitEthernet0/0/1        10.1.1.1         Full
 0.0.0.0         GigabitEthernet0/0/1        10.2.2.2         Full
 0.0.0.0         GigabitEthernet0/0/1        10.3.3.3         2-Way
 ----------------------------------------------------------------------------
 Total Peer(s):     3

BDR Cannot Be Elected on the Network

If the ospf dr-priority command is run on GE0/0/1 of R2, R3, and R4 to set the interface DR priority to 0, the three routers are unqualified for DR/BDR election and can only work as DR others. Only one router (R1) on the network is qualified for DR/BDR election.

# Check OSPF neighbor information on R1. The following command output shows that R1 is the DR and the BDR field displays None, indicating that no BDR exists on the network.

<R1> display ospf peer

         OSPF Process 1 with Router ID 10.1.1.1
                 Neighbors

 Area 0.0.0.0 interface 192.168.1.1(GigabitEthernet0/0/1)'s neighbors
 Router ID: 10.2.2.2         Address: 192.168.1.2
   State: Full  Mode:Nbr is Master  Priority: 0
   DR: 192.168.1.1  BDR: None   MTU: 0
   Dead timer due in 38  sec
   Retrans timer interval: 5
   Neighbor is up for 00:04:31
   Authentication Sequence: [ 0 ]

 Router ID: 10.3.3.3         Address: 192.168.1.3
   State: Full  Mode:Nbr is Master   Priority: 0
   DR: 192.168.1.1  BDR: None   MTU: 0
   Dead timer due in 35  sec
   Retrans timer interval: 5
   Neighbor is up for 00:03:45
   Authentication Sequence: [ 0 ]

 Router ID: 10.4.4.4         Address: 192.168.1.4
   State: Full  Mode:Nbr is Master   Priority: 0
   DR: 192.168.1.1  BDR: None   MTU: 0
   Dead timer due in 33  sec
   Retrans timer interval: 5
   Neighbor is up for 00:03:36
   Authentication Sequence: [ 0 ]

# Check brief OSPF neighbor information on R1, R2, R3, and R4. The following command outputs show that R2, R3, and R4 establish adjacencies with R1, respectively, the corresponding states are Full, and the states of neighbor relationships among R2, R3, and R4 are 2-Way.

<R1> display ospf 1 peer brief

         OSPF Process 1 with Router ID 10.1.1.1
                   Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id         Interface                  Neighbor id      State
 0.0.0.0         GigabitEthernet0/0/1       10.2.2.2         Full
 0.0.0.0         GigabitEthernet0/0/1       10.3.3.3         Full
 0.0.0.0         GigabitEthernet0/0/1       10.4.4.4         Full
 ----------------------------------------------------------------------------
 Total Peer(s):     3
<R2> display ospf 1 peer brief

         OSPF Process 1 with Router ID 10.2.2.2
                   Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id         Interface                  Neighbor id      State
 0.0.0.0         GigabitEthernet0/0/1       10.1.1.1         Full
 0.0.0.0         GigabitEthernet0/0/1       10.3.3.3         2-Way
 0.0.0.0         GigabitEthernet0/0/1       10.4.4.4         2-Way
 ----------------------------------------------------------------------------
 Total Peer(s):     3
<R3> display ospf 1 peer brief

         OSPF Process 1 with Router ID 10.3.3.3
                   Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id         Interface                  Neighbor id      State
 0.0.0.0         GigabitEthernet0/0/1       10.1.1.1         Full
 0.0.0.0         GigabitEthernet0/0/1       10.2.2.2         2-Way
 0.0.0.0         GigabitEthernet0/0/1       10.4.4.4         2-Way
 ----------------------------------------------------------------------------
 Total Peer(s):     3
<R4> display ospf 1 peer brief

         OSPF Process 1 with Router ID 10.4.4.4
                   Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id         Interface                  Neighbor id      State
 0.0.0.0         GigabitEthernet0/0/1       10.1.1.1         Full
 0.0.0.0         GigabitEthernet0/0/1       10.2.2.2         2-Way
 0.0.0.0         GigabitEthernet0/0/1       10.3.3.3         2-Way
 ----------------------------------------------------------------------------
 Total Peer(s):     3

In conclusion, if only one router on a broadcast network is qualified for DR/BDR election, the router becomes the DR, no BDR exists on the network, and all the other routers only establish adjacencies with the DR.

DR and BDR Cannot Be Elected on the Network

Based on the preceding configuration, if the ospf dr-priority command is run on GE0/0/1 of R1 to set the interface DR priority to 0, R1 is also unqualified for DR/BDR election. No router on the network is qualified for DR/BDR election.

# Check OSPF neighbor information on R1. The following command output shows that both the DR and BDR fields display None, indicating that no DR or BDR exists on the network.

<R1> display ospf peer

         OSPF Process 1 with Router ID 10.1.1.1
                 Neighbors

 Area 0.0.0.0 interface 192.168.1.1(GigabitEthernet0/0/1)'s neighbors
 Router ID: 10.2.2.2         Address: 192.168.1.2
   State: Full  Mode:Nbr is Master  Priority: 0
   DR: None  BDR: None   MTU: 0
   Dead timer due in 38  sec
   Retrans timer interval: 5
   Neighbor is up for 00:00:00
   Authentication Sequence: [ 0 ]

 Router ID: 10.3.3.3         Address: 192.168.1.3
   State: Full  Mode:Nbr is Master   Priority: 0
   DR: None  BDR: None   MTU: 0
   Dead timer due in 35  sec
   Retrans timer interval: 5
   Neighbor is up for 00:00:00
   Authentication Sequence: [ 0 ]

 Router ID: 10.4.4.4         Address: 192.168.1.4
   State: Full  Mode:Nbr is Master   Priority: 0
   DR: None  BDR: None   MTU: 0
   Dead timer due in 33  sec
   Retrans timer interval: 5
   Neighbor is up for 00:00:00
   Authentication Sequence: [ 0 ]

# Check brief OSPF neighbor information on R1, R2, R3, and R4. The following command outputs show that the states of all neighbor relationships are 2-Way, no adjacency can be established on the network, and routers cannot exchange routing information.

<R1> display ospf 1 peer brief

         OSPF Process 1 with Router ID 10.1.1.1
                   Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id         Interface                  Neighbor id      State
 0.0.0.0         GigabitEthernet0/0/1       10.2.2.2         2-Way
 0.0.0.0         GigabitEthernet0/0/1       10.3.3.3         2-Way
 0.0.0.0         GigabitEthernet0/0/1       10.4.4.4         2-Way
 ----------------------------------------------------------------------------
 Total Peer(s):     3
<R2> display ospf 1 peer brief

         OSPF Process 1 with Router ID 10.2.2.2
                   Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id         Interface                  Neighbor id      State
 0.0.0.0         GigabitEthernet0/0/1       10.1.1.1         2-Way
 0.0.0.0         GigabitEthernet0/0/1       10.3.3.3         2-Way
 0.0.0.0         GigabitEthernet0/0/1       10.4.4.4         2-Way
 ----------------------------------------------------------------------------
 Total Peer(s):     3
<R3> display ospf 1 peer brief

         OSPF Process 1 with Router ID 10.3.3.3
                   Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id         Interface                  Neighbor id      State
 0.0.0.0         GigabitEthernet0/0/1       10.1.1.1         2-Way
 0.0.0.0         GigabitEthernet0/0/1       10.2.2.2         2-Way
 0.0.0.0         GigabitEthernet0/0/1       10.4.4.4         2-Way
 ----------------------------------------------------------------------------
 Total Peer(s):     3
<R4> display ospf 1 peer brief

         OSPF Process 1 with Router ID 10.4.4.4
                   Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id         Interface                  Neighbor id      State
 0.0.0.0         GigabitEthernet0/0/1       10.1.1.1         2-Way
 0.0.0.0         GigabitEthernet0/0/1       10.2.2.2         2-Way
 0.0.0.0         GigabitEthernet0/0/1       10.3.3.3         2-Way
 ----------------------------------------------------------------------------
 Total Peer(s):     3

In conclusion, if no router on a broadcast network is qualified for DR/BDR election, the network has no DR or BDR, and routers on the network do not establish adjacencies. In this case, the states of all neighbor relationships among these routers are 2-Way.

Which three OSPF states are involved when two routers are forming an adjacency choose three?

The Down, Init, and Two-way states are involved in the phase of neighboring router adjacency establishment.

What is the order of preference for choosing the router ID of an OSPF router?

OSPF uses the following criteria to select the router ID: Manual configuration of the router ID. Highest IP address on a loopback interface. Highest IP address on a non-loopback interface.

What will an OSPF router prefer to use first as a router ID?

What will an OSPF router prefer to use first as a router-id? The first preference for an OSPF router ID is an explicitly configured 32-bit address. This address is not included in the routing table and is not defined by the network command.

What is the format of the router ID on an OSPF

A router ID is a 32-bit number formatted like an IPv4 address and assigned in order to uniquely identify a router among OSPF peers.