Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Example: Dynamically Adjusting OSPF Interface Metrics Based on Bandwidth

This example shows how to dynamically adjust OSPF interface metrics based on bandwidth.

Requirements

Before you begin:

Overview

You can specify a set of bandwidth threshold values and associated metric values for an OSPF interface. When the bandwidth of an interface changes, the Junos OS automatically sets the interface metric to the value associated with the appropriate bandwidth threshold value. When you configure bandwidth-based metric values, you typically configure multiple bandwidth and metric values.

In this example, you configure OSPF interface ae0 for bandwidth-based metrics by including the bandwidth-based-metrics statement and the following settings:

  • bandwidth—Specifies the bandwidth threshold in bits per second. The range is 9600 through 1,000,000,000,000,000.
  • metric—Specifies the metric value to associate with a specific bandwidth value. The range is 1 through 65,535.

Configuration

CLI Quick Configuration

To quickly configure bandwidth threshold values and associated metric values for an OSPF interface, copy the following commands, remove any line breaks, and then paste the commands into the CLI.

[edit]set protocols ospf area 0.0.0.0 interface ae0.0 metric 5set protocols ospf area 0.0.0.0 interface ae0.0 bandwidth-based-metrics bandwidth 1g metric 60set protocols ospf area 0.0.0.0 interface ae0.0 bandwidth-based-metrics bandwidth 10g metric 50

Step-by-Step Procedure

To configure the metric for a specific OSPF interface:

  1. Create an OSPF area.

    Note: To specify OSPFv3, include the ospf3 statement at the [edit protocols] hierarchy level.

    [edit]user@host# edit protocols ospf area 0.0.0.0
  2. Configure the metric of the OSPF network segment.
    [edit protocols ospf area 0.0.0.0 ]user@host# set interface ae0 metric 5
  3. Configure the bandwidth threshold values and associated metric values.
    [edit protocols ospf area 0.0.0.0 ]user@host# set interface ae0.0 bandwidth-based-metrics bandwidth 1g metric 60user@host# set interface ae0.0 bandwidth-based-metrics bandwidth 10g metric 50
  4. If you are done configuring the device, commit the configuration.
    [edit protocols ospf area 0.0.0.0 ]user@host# commit

Results

Confirm your configuration by entering the show protocols ospf command. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.

user@host# show protocols ospf area 0.0.0.0 { interface ae0.0 { bandwidth-based-metrics {bandwidth 1g metric 60;bandwidth 10g metric 50;}metric 5;}}

To confirm your OSPFv3 configuration, enter the show protocols ospf3 command.

Verification

Confirm that the configuration is working properly.

Verifying the Configured Metric

Purpose

Verify the metric setting on the interface. Confirm that the Cost field displays the interface’s configured metric (cost). When choosing paths to a destination, OSPF uses the path with the lowest cost.

Action

From operational mode, enter the show ospf interface detail command for OSPFv2, and enter the show ospf3 interface detail command for OSPFv3.

Published: 2012-06-13