Tuesday, September 10, 2013

OSPF Designated Router Election

OSPF force DR election


A designated router (DR) is the router interface elected among all routers on a particular multiaccess network segment, generally assumed to be broadcast multiaccess. The basic neighbor discovery process (Hello), flooding (224.0.0.6), DR election (priority, RID). Special techniques, often vendor-dependent, may be needed to support the DR function on nonbroadcast multiaccess (NBMA) media. It is usually wise to configure the individual virtual circuits of a NBMA subnet as individual point-to-point lines; the techniques used are implementation-dependent.
Do not confuse the DR with an OSPF router type. A given physical router can have some interfaces that are designated (DR), others that are backup designated (BDR), and others that are non-designated. If no router is DR or BDR on a given subnet, the BDR is first elected, and then a second election is held for the DR.

I have created a small Backbone area with three OSPF speaking routers. We can use this small scenario to see the election finished for the DR and the BDR. And also we can force our DR selection process. 


The configs are very simple. Every router has a Loopback IP, that is used as a ROUTER-ID in the OSPF domain. All the routers belong to the AREA 0 and have their connected networks associated to the area.

R1
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface FastEthernet0/0
 ip address 172.16.1.1 255.255.255.0
 duplex auto
 speed auto
!
router ospf 1
 router-id 1.1.1.1
 log-adjacency-changes
 network 1.1.1.1 0.0.0.0 area 0
 network 172.16.1.0 0.0.0.255 area 0

R2
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
 ip address 172.16.1.2 255.255.255.0
 duplex auto
 speed auto
!
router ospf 1
 router-id 2.2.2.2
 log-adjacency-changes
 network 2.2.2.2 0.0.0.0 area 0
 network 172.16.1.0 0.0.0.255 area 0

R3
interface Loopback0
 ip address 3.3.3.3 255.255.255.255
!
interface FastEthernet0/0
 ip address 172.16.1.3 255.255.255.0
 duplex auto
 speed auto
!
router ospf 1
 router-id 3.3.3.3
 log-adjacency-changes
 network 3.3.3.3 0.0.0.0 area 0
 network 172.16.1.0 0.0.0.255 area 0

To verify the DR and the BDR election , we can see the neighbor relationship on the R3. 

R3#sh ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   FULL/DR         00:00:36    172.16.1.1      FastEthernet0/0
2.2.2.2           1   FULL/BDR        00:00:32    172.16.1.2      FastEthernet0/0

As we can see , the default election OSPF mechanism used the lowest IP address to elect the DR in the broadcast domain we have created. We can also check the status of the OSPF interface and see the priority for the OSPF election process. 

R1#sh ip ospf interface fastEthernet 0/0
FastEthernet0/0 is up, line protocol is up
  Internet Address 172.16.1.1/24, Area 0
  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 1.1.1.1, Interface address 172.16.1.1
  Backup Designated router (ID) 2.2.2.2, Interface address 172.16.1.2
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:02
  Supports Link-local Signaling (LLS)
  Index 2/2, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 2, Adjacent neighbor count is 2
    Adjacent with neighbor 2.2.2.2  (Backup Designated Router)
    Adjacent with neighbor 3.3.3.3
  Suppress hello for 0 neighbor(s)

We can see a lot from this output. By default the OSPF uses the Highest Priority number for the DR election, and if every router in the BROADCAST network has the same, the the tie breaker is the lowest router-id.

Now we should change the topology. Say the the R3 has higher CPU resoruces and NVRAM capabalities, we will for the OSPF protocol to elect the R3 to become the Designated router for our broadcast network. This is done via a simple command on the interfaces that are responsible for the OSPF Hello packet sending, in our case the F0/0.

R1
R1(config)#interface fastEthernet 0/0
R1(config-if)#ip ospf priority 0
!
R1#clear ip ospf process
Reset ALL OSPF processes? [no]: y

R2
R2(config)#interface fastEthernet 0/0
R2(config-if)#ip ospf priority 0
!
R2#clear ip ospf process
Reset ALL OSPF processes? [no]: y

We have disabled the possibility for the R1 and R2 to become the DR router. After a couple of second we will setup the new , higher priority on the routers, that will force the R3 to become the DR, inspite of the highest router-id.

R1
R1(config)#interface fastEthernet 0/0
R1(config-if)#ip ospf priority 254
!
R1#clear ip ospf process
Reset ALL OSPF processes? [no]: y

R2
R2(config)#interface fastEthernet 0/0
R2(config-if)#ip ospf priority 255
!
R2#clear ip ospf process
Reset ALL OSPF processes? [no]: y

Now to verify the final output. 

R1#sh ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2         255   FULL/BDR        00:00:33    172.16.1.2      FastEthernet0/0
3.3.3.3           1   FULL/DR         00:00:37    172.16.1.3      FastEthernet0/0

We can now see that the R3 is the Designated router for the 172.16.1.0/24 subnet and the R2 has been relected as the Backup Designated router.
This is all to it.

Feel free to comment.

No comments:

Post a Comment