How to Configure OSPF Priority on Cisco IOS XR
This is the command for setting the OSPF DR/BDR priority on Cisco IOS XR. You specify it in the interface submode under router ospf. For the roles of DR and BDR and how the election works, see OSPF DR and BDR.
router ospf [PROCESS_NAME]
area [AREA_ID]
interface [INTERFACE_NAME]
priority [PRIORITY]
!
!
!| Field | Value |
|---|---|
| [PRIORITY] | 0 to 255. The default is 1. The higher the value, the more likely the router becomes the DR. A value of 0 means the router never becomes DR or BDR |
Priority only matters on broadcast networks. Point-to-point links do not elect a DR or BDR, so setting it there has no effect.
Where the Setting Can Be Written
Priority can be written directly under router ospf, under area, or under interface. A value written at a higher level is inherited by the lower levels, and a value written at a lower level takes precedence. Write it under the interface when it differs per segment, and directly under the process when it should be the same across the device.
router ospf [PROCESS_NAME]
area [AREA_ID]
priority [PRIORITY]
interface [INTERFACE_NAME]
!
!
!ip ospf priority <value> under interface. The range (0 to 255) and the default (1) are the same as IOS XR, but IOS XR differs in that the value can also be written at the process and area levels and is inherited downwards.Cisco IOS XR Priority Verification Commands
| Command | What it shows |
|---|---|
show ospf interface brief | The state of each interface (DR / BDR / DROTHER) and its neighbor count. A one-line-per-interface view of the roles |
show ospf interface [INTERFACE_NAME] | The priority of that interface, the router ID and address of the DR and BDR, and the Wait timer |
show ospf neighbor | The priority of each neighbor (the Pri column) and its state (FULL/DR, FULL/BDR, 2WAY/DROTHER) |
show ospf neighbor detail | Per-neighbor priority and DR/BDR details |
show running-config router ospf | The configured priority values |
DROTHERs do not form adjacencies with each other, so show ospf neighbor shows them as 2WAY/DROTHER. That is not a fault.
clear ospf <process-name> process does this but prompts with Reset OSPF process? [no]:. process restart ospf achieves the same thing without a prompt.Verification on Real Devices
We connected four routers, XR1 to XR4, to a single Ethernet segment (10.0.0.0/24) and varied the priority to observe the election result.
| Router | Router ID | Priority | Expected role |
|---|---|---|---|
| XR1 | 1.1.1.1 | 100 | DR |
| XR2 | 2.2.2.2 | 50 | BDR |
| XR3 | 3.3.3.3 | 0 | DROTHER (excluded from the election) |
| XR4 | 4.4.4.4 | default 1 | DROTHER |
XR4 has the highest router ID but the lowest priority, so it becomes a DROTHER. The layout shows that priority takes precedence over the router ID.
Configuring the Priority
router ospf 1
router-id 1.1.1.1
area 0
interface Loopback0
passive enable
!
interface GigabitEthernet0/0/0/0
priority 100
!
!
!router ospf 1
router-id 2.2.2.2
area 0
interface Loopback0
passive enable
!
interface GigabitEthernet0/0/0/0
priority 50
!
!
!router ospf 1
router-id 3.3.3.3
area 0
interface Loopback0
passive enable
!
interface GigabitEthernet0/0/0/0
priority 0
!
!
!router ospf 1
router-id 4.4.4.4
area 0
interface Loopback0
passive enable
!
interface GigabitEthernet0/0/0/0
!
!
!XR4 has no priority configured. It runs with the default of 1.
Here is the configuration being entered on XR1.
RP/0/RP0/CPU0:XR1#configure
Thu Sep 10 07:14:19.388 UTC
RP/0/RP0/CPU0:XR1(config)#router ospf 1
RP/0/RP0/CPU0:XR1(config-ospf)#router-id 1.1.1.1
RP/0/RP0/CPU0:XR1(config-ospf)#area 0
RP/0/RP0/CPU0:XR1(config-ospf-ar)#interface Loopback0
RP/0/RP0/CPU0:XR1(config-ospf-ar-if)#passive enable
RP/0/RP0/CPU0:XR1(config-ospf-ar-if)#exit
RP/0/RP0/CPU0:XR1(config-ospf-ar)#interface GigabitEthernet0/0/0/0
RP/0/RP0/CPU0:XR1(config-ospf-ar-if)#priority 100
RP/0/RP0/CPU0:XR1(config-ospf-ar-if)#exit
RP/0/RP0/CPU0:XR1(config-ospf-ar)#commit
Thu Sep 10 07:14:20.556 UTC
RP/0/RP0/CPU0:XR1(config-ospf-ar)#end
RP/0/RP0/CPU0:XR1#show running-config router ospf
Thu Sep 10 07:14:23.091 UTC
router ospf 1
router-id 1.1.1.1
area 0
interface Loopback0
passive enable
!
interface GigabitEthernet0/0/0/0
priority 100
!
!
!Verifying the Configuration
show ospf interface brief shows the roles. XR1 has the highest priority, so it becomes the DR and is adjacent to all three other routers on the segment.
RP/0/RP0/CPU0:XR1#show ospf interface brief
Thu Sep 10 07:17:19.803 UTC
* Indicates MADJ interface, (P) Indicates fast detect hold down state
Interfaces for OSPF 1
Interface PID Area IP Address/Mask Cost State Nbrs F/C
Lo0 1 0 1.1.1.1/32 1 LOOP 0/0
Gi0/0/0/0 1 0 10.0.0.1/24 1 DR 3/3The Pri column of show ospf neighbor shows each router’s priority. Seen from XR1, the DR, all three routers are FULL.
RP/0/RP0/CPU0:XR1#show ospf neighbor
Thu Sep 10 07:17:20.527 UTC
* Indicates MADJ interface
# Indicates Neighbor awaiting BFD session up
Neighbors for OSPF 1
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 50 FULL/BDR 00:00:31 10.0.0.2 GigabitEthernet0/0/0/0
Neighbor is up for 00:01:05
3.3.3.3 0 FULL/DROTHER 00:00:32 10.0.0.3 GigabitEthernet0/0/0/0
Neighbor is up for 00:01:03
4.4.4.4 1 FULL/DROTHER 00:00:35 10.0.0.4 GigabitEthernet0/0/0/0
Neighbor is up for 00:01:00
Total neighbor count: 3The view from XR4, a DROTHER, is different. It is FULL with XR1 (the DR) and XR2 (the BDR), but stays at 2WAY/DROTHER with XR3, the other DROTHER. DROTHERs do not form adjacencies with each other, so this is not a fault.
RP/0/RP0/CPU0:XR4#show ospf neighbor
Thu Sep 10 07:18:16.904 UTC
* Indicates MADJ interface
# Indicates Neighbor awaiting BFD session up
Neighbors for OSPF 1
Neighbor ID Pri State Dead Time Address Interface
1.1.1.1 100 FULL/DR 00:00:38 10.0.0.1 GigabitEthernet0/0/0/0
Neighbor is up for 00:02:04
2.2.2.2 50 FULL/BDR 00:00:30 10.0.0.2 GigabitEthernet0/0/0/0
Neighbor is up for 00:02:02
3.3.3.3 0 2WAY/DROTHER 00:00:32 10.0.0.3 GigabitEthernet0/0/0/0
Neighbor is up for 00:02:00
Total neighbor count: 3Looking at the interface on XR3, which is set to priority 0, it reports State DROTHER, Priority 0. It does not become the BDR despite having a higher router ID than XR2, because priority 0 is excluded from the election. It is adjacent only to the DR and the BDR.
RP/0/RP0/CPU0:XR3#show ospf interface GigabitEthernet0/0/0/0
Thu Sep 10 07:18:32.459 UTC
GigabitEthernet0/0/0/0 is up, line protocol is up
Internet Address 10.0.0.3/24, Area 0, SID 0, Strict-SPF SID 0
Label stack Primary label 0 Backup label 0 SRTE label 0
Process ID 1, Router ID 3.3.3.3, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DROTHER, Priority 0, MTU 1500, MaxPktSz 1500
Forward reference No, Unnumbered no, Bandwidth 1000000
RIB LC sync Yes
Designated Router (ID) 1.1.1.1, Interface address 10.0.0.1
Backup Designated router (ID) 2.2.2.2, Interface address 10.0.0.2
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:04:559
Index 2/2, flood queue length 0
Next 0(0)/0(0)
Last flood scan length is 0, maximum is 1
Last flood scan time is 0 msec, maximum is 0 msec
LS Ack List: current length 0, high water mark 3
Neighbor Count is 3, Adjacent neighbor count is 2
Adjacent with neighbor 1.1.1.1 (Designated Router)
Adjacent with neighbor 2.2.2.2 (Backup Designated Router)
Suppress hello for 0 neighbor(s)
Multi-area interface Count is 0
Segment Routing Forwarding MPLS enabled: Yes
Adjacency hold timer expired last : Never
Exchange timer expired last : NeverTest Configuration and show Output
The following three kinds of output were collected from all four routers, split per router. The test configuration is these ..._run.txt files.
| File | Contents |
|---|---|
..._show.txt | show version / show interface description / show route / show route ospf / show ospf / show ospf interface / show ospf interface brief / show ospf neighbor / show ospf neighbor detail / show ospf database / show ospf database router / show ospf database network / show ospf statistics interface / show ospf routes / show ospf statistics / show router-id / show ospf trace events |
..._log.txt | show logging, taken by inserting a marker with logmsg just before configuring OSPF and passing its timestamp to show logging start |
..._run.txt | show running-config (that is, the test configuration) |
| Router | show output | syslog | running-config |
|---|---|---|---|
| XR1 | show | log | run |
| XR2 | show | log | run |
| XR3 | show | log | run |
| XR4 | show | log | run |
Related Articles
For how DR and BDR work, see OSPF DR and BDR. For basic OSPF configuration, see IOS XR OSPF Basic Configuration.