Manipulating DR Selection

Problem

You want to manipulate the Designated Router (DR) selection process on a particular subnet.

Solution

The ip ospf priority configuration command allows you to weight the Designated Router (DR) selection process on a network segment. The following configuration examples are for three different routers that all share the same Ethernet segment. Router5 has the highest OSPF priority, so it will become the DR. Router1 has the second highest priority because we want it to be the Backup Designated Router (BDR).

Router1 is connected to this network segment through a VLAN trunk:

Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#interface FastEthernet0/0.1 Router1(config-subif)#ip ospf priority 2 Router1(config-subif)#exit Router1(config)#end Router1#

We will configure Router3 with a priority of 0. The default priority is 1. A router with priority 0 will never become the DR or BDR:

Router3#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router3(config)#interface FastEthernet0/0.1 Router3(config-subif)#ip ospf priority 0 Router3(config-subif)#exit Router3(config)#end Router3#

Router5 has the highest priority, so it will become the DR for the segment:

Router5#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router5(config)#interface Ethernet0 Router5(config-if)#ip ospf priority 10 Router5(config-if)#exit Router5(config)#end Router5#

 

Discussion

There are several reasons for rigging the DR election process, as we have done in this recipe. The most common reason is simply to ensure that the router closest to the network core is responsible for distributing routing information. This is actually a somewhat aesthetic requirement, because all of the routers in an area see all of the LSAs for that area, so nobody's routing table is more accurate than anybody else's. But it can result in faster convergence in some network configurations.

But there are two times when it is critical to force a particular router to become the DR. The first is when you are using MOSPF to handle multicast routing. MOSPF uses the same DR as regular OSPF. So if you have a mix of MOSPF and regular OSPF on the same segment, it is critical that an MOSPF router be the DR, or no multicast routes will be distributed. Because Cisco routers do not support MOSPF, this means that you must set the priority to 0 for all Cisco routers on such a segment.

The second place where DR selection is critical is in Nonbroadcast Multiple Access (NBMA) networks. A typical example of this would be a Frame Relay WAN that uses multipoint subinterfaces, as described in Recipe 10.4. In this case, all of the routers are members of the same subnet, but only the central hub router can talk directly to the branch devices. A branch router should never act as DR because it can't talk directly to any of the other branches. The central router is the only device that can be the DR, or the routing updates will not work.

If you don't adjust the priorities to help force a particular winner to the DR election, the DR will be the router with the highest Router ID (RID) value. See Recipe 8.8 for a discussion of RID values.

It is important to note that setting a higher priority can help to rig the DR election process, but it doesn't guarantee that another lower priority router device won't become DR if it happens to be there first. And if a higher priority router comes up on a segment that already has a DR, it will not preempt either the DR or the BDR. If the higher priority router isn't available when a lower priority router joins the segment, then the lower priority router will become DR. Once a router is DR, it will remain DR until you either manually reset the neighbor relationships or until there is a network failure on the segment that forces the change.

The exception to this rule is when you configure a router with a priority of 0. In this case, the router will never become DR, even if it is the only router on the segment.

You can see the state of all of the neighboring routers on a segment with the show ip ospf neighbor command:

Router5#show ip ospf neighbor Ethernet0 Neighbor ID Pri State Dead Time Address Interface Router1 2 FULL/BDR 00:00:31 172.25.1.5 Ethernet0 Router3 0 FULL/DROTHER 00:00:31 172.25.1.3 Ethernet0 Router4 1 FULL/DROTHER 00:00:39 172.25.1.1 Ethernet0 Router5#

In this output, we have asked the router to only show the neighbors on the Ethernet0 interface. You can see that Router1 is the BDR, and the other two routers on the segment have a state of DROTHER. This means that they are neither DR nor BDR, but are neighbors. Notice that none of the routers listed is the DR. This is because the router we typed this on was the DR itself.

You can verify that this router is the DR, and that it has a priority of 10 with the show ip ospf interface command:

Router5#show ip ospf interface Ethernet0 is up, line protocol is up Internet Address 172.25.1.7/24, Area 0 Process ID 87, Router ID 172.25.1.7, Network Type BROADCAST, Cost: 10 Transmit Delay is 1 sec, State DR, Priority 10 Designated Router (ID) 172.25.25.6, Interface address 172.25.1.7 Backup Designated router (ID) Router1, Interface address 172.25.1.3 Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 Hello due in 00:00:03 Neighbor Count is 3, Adjacent neighbor count is 3 Adjacent with neighbor Router3 Adjacent with neighbor Router1 (Backup Designated Router) Adjacent with neighbor Router4 Suppress hello for 0 neighbor(s) Router5#

In the following example, we have increased the priority of Router4 to 10, as well. However, as you can see, not only does it not pre-empt the DR, it doesn't even pre-empt the BDR:

Router5#show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface Router4 10 FULL/DROTHER 00:00:30 172.25.1.5 Ethernet0 Router1 2 FULL/BDR 00:00:38 172.25.1.3 Ethernet0 Router3 0 FULL/DROTHER 00:00:30 172.25.1.1 Ethernet0 Router5#

Because higher priority routers will not pre-empt existing DR and BDR routers, if there are routers that should not become DR for any reason, you should be careful to set their priorities to 0. Otherwise, you may find that the DR is simply the router that has been active for the longest time, instead of the one that you actually wanted.

See Also

Recipe 8.8; Recipe 10.4; Recipe 23.10

Категории