OSPF prefers the lowest cost path to determine the best route. While OSPF doesn’t use administrative distance directly for path control like other protocols (e.g., EIGRP or BGP), there are several effective methods to manipulate OSPF routes.
1. OSPF Cost Manipulation (Recommended Method)
The most common method to influence OSPF path selection is by adjusting the interface cost.
πΉ Cost Calculation Formula
Cost=Reference BandwidthInterface Bandwidth\text{Cost} = \frac{\text{Reference Bandwidth}}{\text{Interface Bandwidth}}Cost=Interface BandwidthReference Bandwidthβ
- Default Reference Bandwidth = 100 Mbps (can be adjusted for higher-speed links).
- To modify reference bandwidth:
Router(config-router)# auto-cost reference-bandwidth 10000
(Recommended for networks with gigabit or higher-speed links)
πΉ Cost Adjustment Command
To modify the OSPF cost directly on an interface:
Router(config-if)# ip ospf cost <value>
β
Higher Cost = Less Preferred Path
β
Lower Cost = More Preferred Path
Example Topology
R1 ----- 100 Mbps ----- R2
R1 ----- 10 Mbps ------ R3 ----- 1 Gbps ------ R2
- Default Cost via R2 (direct): 1
- Default Cost via R3: 10 (10 Mbps) + 1 (1 Gbps) = 11
π To prefer the R3 path, configureip ospf costto 12 on the R1-R2 link.
2. OSPF Metric Manipulation Using Bandwidth
Since OSPF calculates cost based on bandwidth by default, modifying the bandwidth also manipulates the path.
πΉ Bandwidth Command
Router(config-if)# bandwidth <value in kbps>
β Note: The bandwidth command only influences OSPF cost calculations β it does not change the actual interface speed.
3. Route Summarization (On ABRs/ASBRs)
Summarization helps reduce the LSDB size and can influence path selection by controlling route advertisements.
πΉ ABR Summarization (Inter-Area)
Router(config-router)# area <area-id> range <network> <mask>
πΉ ASBR Summarization (External Routes)
Router(config-router)# summary-address <network> <mask>
β
Summarized routes are preferred over more specific routes with the same cost.
β
Helps control the size of the routing table in large networks.
4. OSPF Route Filtering
OSPF supports filtering routes using:
πΉ distribute-list (Inbound Filtering)
- Filters routes before being installed in the routing table.
Router(config-router)# distribute-list <ACL> in <interface>
πΉ area <area-id> filter-list (Inter-Area Filtering)
- Filters Type 3 LSAs between areas (only on ABRs).
Router(config-router)# area 1 filter-list prefix <prefix-list> in
πΉ route-map with redistribute (Advanced Control)
- Used on ASBRs when redistributing external routes into OSPF.
Router(config-router)# route-map FILTER permit 10
Router(config-route-map)# match ip address 10
Router(config-router)# redistribute static subnets route-map FILTER
5. OSPF Priority (DR/BDR Election Control)
In multi-access networks (like Ethernet), OSPF priority determines which router becomes the DR/BDR.
πΉ Command to Modify OSPF Priority
Router(config-if)# ip ospf priority <value>
β
Higher Priority = Preferred DR
β
Priority 0 = Never a DR/BDR
6. OSPF Administrative Distance (Rarely Used)
The default OSPF administrative distance is:
- 110 for internal OSPF routes
- 120 for external OSPF routes
Though modifying the AD isnβt ideal for OSPF manipulation, it can be done:
πΉ Command to Change OSPF AD
Router(config-router)# distance <value> <source-ip> <wildcard-mask>
7. Floating Static Routes (Backup Path)
To create a backup route in case the OSPF path fails, use a floating static route with a higher AD:
Router(config)# ip route <destination> <mask> <next-hop> <higher AD>
8. Path Preference Example Scenario
Scenario
- Primary Link (R1 β R2) β 1 Gbps
- Backup Link (R1 β R3 β R2) β 100 Mbps
Objective: Prefer the backup link.
Solution
- Use
ip ospf costto assign a higher cost to the primary link.
R1(config-if)# interface gig0/1
R1(config-if)# ip ospf cost 50
- Alternatively, modify bandwidth:
R1(config-if)# interface gig0/1
R1(config-if)# bandwidth 10000
9. Best Practices for OSPF Path Manipulation
β
Prefer ip ospf cost for precise control.
β
Use bandwidth adjustments cautiously, as it may affect QoS and other protocols.
β
Summarize routes to reduce LSDB size in large networks.
β
Implement route filtering for fine-tuned path control.
β
Maintain Area 0 as the backbone to ensure stable OSPF behavior.
Leave a comment