Adjusting OSPF Link Costs

Table of contents:

Problem

You want to direct traffic within an OSPF area toward a particular interface.

Solution

Increase the cost on one interface to have OSPF use a different interface:

	[edit protocols ospf area 0.0.0.0 ]
	aviva@RouterJ# set interface fe-1/0/0.0 meTRic 3 

Discussion

When choosing paths to a destination, OSPF uses the one with the lowest metric. By default, all links faster than 100 Mbps have a metric of 1. This recipe shows how to adjust the metric in our three-router backbone area so that traffic from RouterH always goes through RouterG instead of directly to RouterJ. You might want to do this if the interface between RouterH and RouterJ is congested with other traffic (see Figure 12-1).

With the default metric, traffic from RouterH to RouterJ goes out interface fe-1/0/0, which is one hop away:

	aviva@RouterJ> show route 192.168.18.1
	inet.0: 12 destinations, 12 routes (12 active, 0 holddown, 0 hidden)
	+ = Active Route, - = Last Active, * = Both
	192.168.18.1/32 *[ 
OSPF/10] 00:26:19, metric 1
	 > to 10.0.2.1 via fe-1/0/0.0

Use the traceroute command to verify this:

	[edit protocols ospf area 0.0.0.0 interface fe-1/0/0.0 ]
	aviva@RouterJ# run traceroute 192.168.18.1 
	traceroute to 192.168.18.1 (192.168.18.1), 30 hops max, 40 byte packets
	1 192.168.18.1 (192.168.18.1) 10.905 ms 9.060 ms 9.807 ms

If you change the metric value on the fe-1/0/0 interface to 2, you create an equal-cost path to RouterH:

	[edit protocols ospf area 0.0.0.0]
	aviva@RouterJ# show
	interface fe-1/0/1.0;
	interface fe-1/0/0.0 {
	 metric 2;
	}

The cost is 2, whether packets go through interface fe-1/0/0 or interface fe-1/0/1:

	[edit protocols ospf area 0.0.0.0 ]
	aviva@RouterJ# run show route 192.168.18.1 
	inet.0: 12 destinations, 12 routes (12 active, 0 holddown, 0 hidden)
	+ = Active Route, - = Last Active, * = Both
	192.168.18.1/32 *[OSPF/10] 00:00:08, metric 2 
	 to 10.0.2.1 via fe-1/0/0.0
	 > to 10.0.0.1 via fe-1/0/1.0

Because we want traffic to always go through RouterG, we need to set the metric to something greater than 2, so in this recipe we set it to 3. The traffic now goes along the desired path:

	[edit protocols ospf area 0.0.0.0 ]
	aviva@RouterJ# run show route 192.168.18.1 
	inet.0: 12 destinations, 12 routes (12 active, 0 holddown, 0 hidden)
	+ = Active Route, - = Last Active, * = Both
	192.168.18.1/32 *[OSPF/10] 00:00:06, metric 2 
	 > to 10.0.0.1 via fe-1/0/1.0 

The TRaceroute shows the path through interface 10.0.0.1 on RouterG:

	[edit protocols ospf area 0.0.0.0  interface fe-1/0/0.0 ]
	aviva@RouterJ# run traceroute 192.168.18.1 
	traceroute to 192.168.18.1 (192.168.18.1), 30 hops max, 40 byte packets
	 1 10.0.0.1 (10.0.0.1) 12.170 ms 8.826 ms 9.798 ms
	 2 192.168.18.1 (192.168.18.1) 10.313 ms 15.829 ms 13.332 ms

The interfaces in this recipe are all Fast Ethernet interfaces (100 Mbps), so their default metric is 1. This metric is assigned by OSPF using the following formula:

OSPF uses this formula for all "real" interfaces, which are interfaces that correspond to a physical PIC. In the formula, the default reference bandwidth value is 100 Mbps, which is why Fast Ethernet interfaces have a default metric of 1. For a 10 Mbps Ethernet interface, OSPF assigns a default metric of 10 based on this formula. For interfaces faster than 100 Mbps, OSPF assigns a metric of 1 to them all because the calculated value is a fraction that is less than 1 and OSPF rounds up to 1. Heres the calculation for a Gigabit Ethernet (1,000 Mbps) interface:

The calculation for a SONET OC-192 interface looks like this:

OSPF would assign a default metric of 1 to both these interfaces because all fractions less than 1 are rounded up to 1.

Having the same default metric is not necessarily a problem if all the interfaces are running at the same speed. But if they operate at different speeds, when there are equal-cost paths to the same destination, instead of traffic being routed across the fastest interface, the default behavior is to equally distribute traffic across the different interfaces in a round-robin fashion. To have the interface metrics that OSPF calculates accurately reflect the actual speeds of the interfaces, modify the default reference bandwidth value. As an example, if your router has Fast Ethernet, Gigabit Ethernet, and OC192 interfaces running OSPF, you can set the reference bandwidth to 10 Gbps:

	[edit protocols ospf]
	aviva@RouterJ# set reference-bandwidth 10g

With this configuration, OSPF assigns the Fast Ethernet interface a metric of 100, the Gigabit Ethernet interface a metric of 10, and the OC192 interface a metric of 1. Because the OC192 interface has the lowest metric, OSPF selects it when routing traffic.


Router Configuration and File Management

Basic Router Security and Access Control

IPSec

SNMP

Logging

NTP

Router Interfaces

IP Routing

Routing Policy and Firewall Filters

RIP

IS-IS

OSPF

BGP

MPLS

VPNs

IP Multicast



JUNOS Cookbook
Junos Cookbook (Cookbooks (OReilly))
ISBN: 0596100140
EAN: 2147483647
Year: 2007
Pages: 290
Authors: Aviva Garrett

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net