ip ospf priority [0-255]
Sets the OSPF priority on an interface to influence the Designated Router (DR) and Backup Designated Router (BDR) election process in a broadcast multi-access network.
Definition: ip ospf priority [0-255] is a Cisco IOS interface config command. Sets the OSPF priority on an interface to influence the Designated Router (DR) and Backup Designated Router (BDR) election process in a broadcast multi-access network.
Overview
The `ip osp priority` command is a critical tool for controlling the Designated Router (DR) and Backup Designated Router (BDR) election process on OSPF broadcast multi-access networks, such as Ethernet. In OSPF, on broadcast multi-access segments, a DR and BDR are elected to reduce the number of adjacencies and limit the flooding of LSAs. The DR acts as the central point for exchanging routing information, while the BDR takes over if the DR fails.
By default, the router with the highest OSPF priority becomes the DR, and the second highest becomes the BDR. The priority value ranges from 0 to 255, where 0 means the router is ineligible to become DR or BDR, and 255 is the highest priority. A priority of 1 is the default on Cisco IOS interfaces.
This command is typically used to influence the election in favor of a more capable router (e.g., one with higher CPU or memory) or to ensure a specific router becomes the DR for network stability. It is often applied in hub-and-spoke topologies where the hub router should be the DR. Alternatives include using the `ip ospf priority` command on specific interfaces or adjusting the router ID, but priority is the most direct method. The command is configured in interface configuration mode and takes effect immediately; however, the DR/BDR election is not preemptive—once elected, a router remains DR/BDR until it fails or the OSPF process is reset.
This means that changing priority on an active network will not trigger a new election unless the current DR or BDR goes down. To force a new election, you can clear the OSPF process with `clear ip ospf process` or shut/no-shut the interface. The command is available in all IOS versions and requires privilege level 15.
It is stored in the running configuration and can be saved to startup-config. Understanding this command is essential for designing stable OSPF networks and troubleshooting election issues.
ip ospf priority [0-255]When to Use This Command
- Ensuring a specific router becomes the DR by setting its priority higher than all other routers on the segment.
- Preventing a router from participating in the DR/BDR election by setting its priority to 0, making it a DROTHER.
- Manipulating DR/BDR election results during network maintenance or upgrades.
- Balancing OSPF adjacency roles in a redundant network to control which router handles inter-area routing.
Parameters
| Parameter | Syntax | Description |
|---|---|---|
| priority | <0-255> | Sets the OSPF priority for the interface. Valid values are from 0 to 255. A priority of 0 makes the router ineligible to become DR or BDR. The default priority is 1. Higher values increase the chance of becoming DR/BDR. Common mistakes include setting priority to 0 unintentionally, which prevents the router from participating in the election, or assuming that changing priority triggers an immediate election (it does not). |
Command Examples
Setting OSPF priority to 255 to ensure DR election
interface GigabitEthernet0/0
ip ospf priority 255This command sets the OSPF priority to 255, the highest possible value, ensuring this router becomes the DR on the broadcast segment. No output is generated; the change is applied immediately.
Setting OSPF priority to 0 to prevent DR/BDR participation
interface GigabitEthernet0/1
ip ospf priority 0Setting priority to 0 makes the router ineligible to become DR or BDR. It will only form adjacencies with the DR and BDR. No output is generated.
Understanding the Output
The 'ip ospf priority' command does not produce any output when executed. To verify the configured priority, use 'show ip ospf interface [interface]'. In the output, look for the line 'Priority: <value>'.
A priority of 0 indicates the router will never become DR or BDR. A priority of 1-255 indicates eligibility, with higher values increasing the chance of becoming DR. If priorities are equal, the router with the higher Router ID wins. After changing priority, the DR/BDR election does not occur immediately; it only happens when the current DR or BDR goes down or the OSPF process is reset.
Configuration Scenarios
Ensure a Core Router Becomes the DR on a Broadcast Segment
In a campus network, a core router (R1) connects to two access routers (R2 and R3) via a common VLAN. The core router has higher processing power and should be the DR to optimize LSA flooding. By default, all routers have priority 1, so the DR is chosen based on highest router ID, which may not be the core router.
Topology
R1(Gi0/0)---10.0.12.0/24---(Gi0/0)R2
R1(Gi0/0)---10.0.12.0/24---(Gi0/0)R3Steps
- 1.Step 1: Enter global configuration mode: configure terminal
- 2.Step 2: Enter interface configuration for the VLAN interface: interface GigabitEthernet0/0
- 3.Step 3: Set OSPF priority to a high value (e.g., 100): ip ospf priority 100
- 4.Step 4: Exit configuration mode: end
- 5.Step 5: (Optional) Force a new DR election by clearing the OSPF process: clear ip ospf process
! Configure OSPF priority on R1 interface GigabitEthernet0/0 ip ospf priority 100 ! Ensure OSPF is enabled on the interface router ospf 1 network 10.0.12.0 0.0.0.255 area 0
Verify: Use `show ip ospf interface GigabitEthernet0/0` to verify the priority and DR/BDR status. Expected output includes: 'Priority 100', 'DR: 10.0.12.1' (R1's IP), 'BDR: 10.0.12.2' (R2's IP).
Watch out: If the current DR is already elected, changing priority alone does not trigger a new election. You must either clear the OSPF process or shut/no-shut the interface to force re-election. Also, ensure all routers are in the same OSPF area and network type is broadcast.
Prevent a Router from Becoming DR or BDR
In a branch office, a low-end router (R3) connects to the WAN via a broadcast link. To avoid it becoming DR or BDR (which would burden its limited resources), set its priority to 0. This ensures it never participates in the election and only forms full adjacencies with the DR and BDR.
Topology
R1(Gi0/0)---192.168.1.0/24---(Gi0/0)R2
R1(Gi0/0)---192.168.1.0/24---(Gi0/0)R3Steps
- 1.Step 1: Enter global configuration mode: configure terminal
- 2.Step 2: Enter interface configuration: interface GigabitEthernet0/0
- 3.Step 3: Set OSPF priority to 0: ip ospf priority 0
- 4.Step 4: Exit and verify: end
! On R3, set priority to 0 interface GigabitEthernet0/0 ip ospf priority 0 ! OSPF configuration router ospf 1 network 192.168.1.0 0.0.0.255 area 0
Verify: Use `show ip ospf interface GigabitEthernet0/0` on R3. Expected output: 'Priority 0', 'DR: 192.168.1.1' (R1), 'BDR: 192.168.1.2' (R2), and R3's state should be 'DROTHER'.
Watch out: Setting priority to 0 does not prevent the router from forming adjacencies; it only prevents it from being elected. Also, if all routers on the segment have priority 0, no DR/BDR is elected, and OSPF will not form adjacencies (since broadcast network requires DR/BDR). Ensure at least one router has non-zero priority.
Troubleshooting with This Command
When troubleshooting OSPF DR/BDR election issues, the `show ip ospf interface` command is essential. Healthy output shows the interface state as 'DR', 'BDR', or 'DROTHER' with the correct priority. Key fields to examine: 'Priority' (should match configured value), 'DR ID' and 'BDR ID' (should be the router IDs of the elected routers), and 'State' (should be consistent with the election).
Common symptoms include: a router that should be DR is not elected (check priority and router ID; if priorities are equal, highest router ID wins), or a router with priority 0 is showing as DR (possible misconfiguration). Step-by-step diagnostic flow: 1) Verify OSPF is enabled on the interface with `show ip ospf interface`. 2) Check the priority value; if not as expected, reapply the command. 3) If priority is correct but election is wrong, check the router IDs of all neighbors using `show ip ospf neighbor`. 4) If the current DR is not the desired one, note that election is non-preemptive; you may need to clear the OSPF process with `clear ip ospf process` (causes a brief outage) or shut/no-shut the interface. 5) Use `debug ip ospf adj` to monitor election events (use with caution in production). Correlate with `show ip ospf neighbor` to see neighbor states; if a router is stuck in '2WAY' state, it may be a DROTHER that is not forming full adjacency with other DROTHERs (normal).
If a router is stuck in 'EXSTART' or 'EXCHANGE', it indicates a different issue. Also, ensure the network type is broadcast (default on Ethernet); if it's point-to-point, DR/BDR election does not occur. The `ip ospf priority` command is only relevant on broadcast and non-broadcast multi-access (NBMA) networks.
On point-to-point or point-to-multipoint, priority is ignored. Finally, remember that the DR/BDR election is based on the interface IP address if priorities are equal; the highest IP wins. So if you want a specific router to be DR, set its priority higher than others, or if all priorities are equal, ensure it has the highest IP address on that subnet.
CCNA Exam Tips
Remember that priority only matters on broadcast and non-broadcast multi-access (NBMA) networks; point-to-point links do not use DR/BDR.
The DR/BDR election is non-preemptive: changing priority after election does not force a new election unless the DR or BDR fails.
A priority of 0 means the router is never elected as DR or BDR; it only forms full adjacencies with the DR and BDR.
In the CCNA exam, you may be asked to determine which router becomes DR based on priority and Router ID; higher priority wins, then highest Router ID.
Common Mistakes
Setting priority to 0 on all routers, which prevents any DR/BDR election and can cause OSPF adjacency issues on broadcast networks.
Forgetting that priority changes do not take effect until the current DR or BDR goes down or the OSPF process is reset.
Confusing priority with cost; priority is for DR/BDR election, cost is for route metric calculation.
ip ospf priority [0-255] vs ip ospf cost [value]
Both 'ip ospf priority' and 'ip ospf cost' are interface-level OSPF commands that affect network behavior, but they target different OSPF mechanisms: DR/BDR election and path selection, respectively. They are often confused because both modify OSPF operation on an interface without affecting the adjacency state.
| Aspect | ip ospf priority [0-255] | ip ospf cost [value] |
|---|---|---|
| Purpose | Sets interface priority for DR/BDR election | Sets interface cost (metric) for path calculation |
| Effect | Influences which router becomes DR/BDR in broadcast networks | Influences which path is preferred in the routing table |
| Scope | Only applies on broadcast and NBMA network types | Applies on all OSPF network types |
| Precedence | Higher value increases chance of being DR/BDR (ranges 0-255) | Lower cost makes path more preferred (default derived from bandwidth) |
| Default | Default priority is 1 (0 means never becomes DR/BDR) | Default cost = 10^8 / bandwidth (for bw in bps) |
| Configuration Mode | Interface configuration mode | Interface configuration mode |
Use ip ospf priority [0-255] when you need to control which router becomes the Designated Router or Backup Designated Router on a multi-access segment, for example to force a core router as DR.
Use ip ospf cost [value] when you need to manually adjust the metric of an interface to influence inbound or outbound traffic paths, such as to prefer a higher-bandwidth link despite a lower-bandwidth default cost.
Platform Notes
In IOS-XE (e.g., Catalyst 9000 switches), the `ip ospf priority` command syntax and behavior are identical to classic IOS. The output of `show ip ospf interface` is similar but may include additional fields like 'Wait time' and 'DR/BDR address'. In NX-OS (Cisco Nexus switches), the equivalent command is `ip ospf priority` under interface configuration mode, but note that NX-OS uses a different OSPF configuration style (e.g., `feature ospf` must be enabled).
The syntax is the same: `ip ospf priority <0-255>`. However, NX-OS also supports the `ip ospf passive-interface` command which can affect adjacency formation. On ASA firewalls, OSPF is supported in routed mode, but the command is `ospf priority` under interface configuration (e.g., `ospf priority 10`).
The ASA does not support the `ip ospf priority` command; instead, use `ospf priority`. In IOS-XR (Cisco ASR 9000, etc.), the command is `ospf priority` under the OSPF interface configuration submode (e.g., `router ospf 1`, then `interface GigabitEthernet0/0/0/0`, then `priority 10`). The priority range is the same (0-255).
Note that IOS-XR uses a different configuration hierarchy and requires committing changes. In older IOS versions (12.x), the command is identical to 15.x and 16.x. There are no significant behavioral differences across versions, but the output format of `show ip ospf interface` may vary slightly (e.g., 12.x shows 'Priority' as a separate line, while 15.x+ may include it in the first line).
Always check the specific platform documentation for exact syntax.
Related Commands
ip ospf cost [value]
Manually sets the OSPF cost (metric) on an interface, overriding the default cost derived from bandwidth, to influence path selection in OSPF routing.
router ospf [process-id]
Enable OSPF routing on the router and enter OSPF router configuration mode for a specific process, allowing you to configure OSPF parameters such as network statements, router ID, and area assignments.
show ip ospf interface
Displays OSPF interface parameters and status, used to verify OSPF configuration and troubleshoot neighbor relationships.
Practice for the CCNA 200-301
Test your knowledge with practice questions covering all CCNA 200-301 exam domains.
Practice CCNA 200-301 Questions