Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Example: Associating the MED Path Attribute with the IGP Metric and Delaying MED Updates

This example shows how to associate the multiple exit discriminator (MED) path attribute with the interior gateway protocol (IGP) metric, and configure a timer to delay update of the MED attribute.

Requirements

No special configuration beyond device initialization is required before you configure this example.

Overview

BGP can be configured to advertise the MED attribute for a route based on the IGP distance of its internal BGP (IBGP) route next-hop. The IGP metric enables internal routing to follow the shortest path according to the administrative setup. In some deployments, it might be ideal to communicate IGP shortest-path knowledge to external BGP (EBGP) peers in a neighboring autonomous system (AS). This allows those EBGP peers to forward traffic into your AS using the shortest paths possible.

Routes learned from an EBGP peer usually have a next hop on a directly connected interface, and thus the IGP value is equal to zero. Zero is the value advertised. The IGP metric is a nonzero value when a BGP peer sends third-party next hops that require the local system to perform next-hop resolution—IBGP configurations, configurations within confederation peers, or EBGP configurations that include the multihop command. In these scenarios, it might make sense to associate the MED value with the IGP metric by including the metric-out minimum-igp or metric-out igp option.

The drawback of associating the MED with the IGP metric is the risk of excessive route advertisements when there are IGP instabilities in the network. Configuring a delay for the MED update provides a mechanism to reduce route advertisements in such scenarios. The delay works by slowing down MED updates when the IGP metric for the next hop changes. The approach uses a timer to periodically advertise MED updates. When the timer expires, the MED attribute for routes with metric-out igp delay-updates configured is updated to the current IGP metric of the next hop. The BGP-enabled device sends out advertisements for routes for which the MED attribute has changed.

The delay-updates option identifies the BGP groups (or peers) for which the MED updates must be suppressed. The time for advertising MED updates is set to 10 minutes by default. You can increase the interval up to 600 minutes by including the med-igp-update-interval statement in the routing-options configuration.

Note: If you have nonstop active routing (NSR) enabled and a switchover occurs, the delayed MED updates might be advertised as soon as the switchover occurs.

When you configure the metric-out igp option, the IGP metric directly tracks the IGP cost to the IBGP peer. When the IGP cost goes down, so does the advertised MED value. Conversely, when the IGP cost goes up, the MED value goes up as well.

When you configure the metric-out minimum-igp option, the advertised MED value changes only when the IGP cost to the IBGP peer goes down. An increase in the IGP cost does not affect the MED value. The router monitors and remembers the lowest IGP cost until the routing process (rpd) is restarted. The BGP peer sends an update only if the MED is lower than the previously advertised value or another attribute associated with the route has changed, or if the BGP peer is responding to a refresh route request.

This example uses the metric statement in the OSPF configuration to demonstrate that when the IGP metric changes, the MED also changes after the configured delay interval. The OSPF metric can range from 1 through 65,535.

Figure 1 shows the sample topology.

Figure 1: Topology for Delaying the MED Update

Topology for Delaying the MED Update

In this example, the MED value advertised by Device R1 is associated with the IGP running in AS 1. The MED value advertised by Device R1 impacts the decisions of the neighboring AS (AS 2) when AS 2 is forwarding traffic into AS 1.

Configuration

CLI Quick Configuration

To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level.

Device R1

set interfaces fe-1/2/0 unit 2 description R1->R2set interfaces fe-1/2/0 unit 2 family inet address 10.0.0.1/30set interfaces fe-1/2/1 unit 7 description R1->R4set interfaces fe-1/2/1 unit 7 family inet address 172.16.0.1/30set interfaces lo0 unit 1 family inet address 192.168.0.1/32set protocols bgp group internal type internalset protocols bgp group internal local-address 192.168.0.1set protocols bgp group internal export send-directset protocols bgp group internal neighbor 192.168.0.2set protocols bgp group internal neighbor 192.168.0.3set protocols bgp group external type externalset protocols bgp group external metric-out igp delay-med-updateset protocols bgp group external export send-directset protocols bgp group external peer-as 2set protocols bgp group external neighbor 172.16.0.2set protocols ospf area 0.0.0.0 interface fe-1/2/0.2 metric 600set protocols ospf area 0.0.0.0 interface lo0.1 passiveset policy-options policy-statement send-direct term 1 from protocol directset policy-options policy-statement send-direct term 1 then acceptset routing-options med-igp-update-interval 12set routing-options router-id 192.168.0.1set routing-options autonomous-system 1

Device R2

set interfaces fe-1/2/0 unit 1 description R2->R1set interfaces fe-1/2/0 unit 1 family inet address 10.0.0.2/30set interfaces fe-1/2/1 unit 4 description R2->R3set interfaces fe-1/2/1 unit 4 family inet address 10.0.2.2/30set interfaces lo0 unit 2 family inet address 192.168.0.2/32set protocols bgp group internal type internalset protocols bgp group internal local-address 192.168.0.2set protocols bgp group internal export send-directset protocols bgp group internal neighbor 192.168.0.1set protocols bgp group internal neighbor 192.168.0.3set protocols ospf area 0.0.0.0 interface fe-1/2/0.1set protocols ospf area 0.0.0.0 interface fe-1/2/1.4set protocols ospf area 0.0.0.0 interface lo0.2 passiveset policy-options policy-statement send-direct term 1 from protocol directset policy-options policy-statement send-direct term 1 then acceptset routing-options router-id 192.168.0.2set routing-options autonomous-system 1

Device R3

set interfaces fe-1/2/0 unit 3 description R3->R2set interfaces fe-1/2/0 unit 3 family inet address 10.0.2.1/30set interfaces fe-1/2/1 unit 5 description R3->R5set interfaces fe-1/2/1 unit 5 family inet address 172.16.0.5/30set interfaces lo0 unit 3 family inet address 192.168.0.3/32set protocols bgp group internal type internalset protocols bgp group internal local-address 192.168.0.3set protocols bgp group internal export send-directset protocols bgp group internal neighbor 192.168.0.1set protocols bgp group internal neighbor 192.168.0.2set protocols bgp group external type externalset protocols bgp group external export send-directset protocols bgp group external peer-as 2set protocols bgp group external neighbor 172.16.0.6set protocols ospf area 0.0.0.0 interface fe-1/2/0.3set protocols ospf area 0.0.0.0 interface lo0.3 passiveset policy-options policy-statement send-direct term 1 from protocol directset policy-options policy-statement send-direct term 1 then acceptset routing-options router-id 192.168.0.3set routing-options autonomous-system 1

Device R4

set interfaces fe-1/2/0 unit 8 description R4->R1set interfaces fe-1/2/0 unit 8 family inet address 172.16.0.2/30set interfaces fe-1/2/1 unit 9 description R4->R5set interfaces fe-1/2/1 unit 9 family inet address 10.0.4.1/30set interfaces fe-1/2/2 unit 13 description R4->R6set interfaces fe-1/2/2 unit 13 family inet address 172.16.0.9/30set interfaces lo0 unit 4 family inet address 192.168.0.4/32set protocols bgp group internal type internalset protocols bgp group internal local-address 192.168.0.4set protocols bgp group internal export send-directset protocols bgp group internal neighbor 192.168.0.5set protocols bgp group external type externalset protocols bgp group external export send-directset protocols bgp group external neighbor 172.16.0.10 peer-as 3set protocols bgp group external neighbor 172.16.0.1 peer-as 1set protocols ospf area 0.0.0.0 interface fe-1/2/1.9set protocols ospf area 0.0.0.0 interface lo0.4 passiveset policy-options policy-statement send-direct term 1 from protocol directset policy-options policy-statement send-direct term 1 then acceptset routing-options router-id 192.168.0.4set routing-options autonomous-system 2

Device R5

set interfaces fe-1/2/0 unit 6 description R5->R3set interfaces fe-1/2/0 unit 6 family inet address 172.16.0.6/30set interfaces fe-1/2/1 unit 10 description R5->R4set interfaces fe-1/2/1 unit 10 family inet address 10.0.4.2/30set interfaces fe-1/2/2 unit 11 description R5->R8set interfaces fe-1/2/2 unit 11 family inet address 172.16.0.13/30set interfaces lo0 unit 5 family inet address 192.168.0.5/32set protocols bgp group internal type internalset protocols bgp group internal local-address 192.168.0.5set protocols bgp group internal export send-directset protocols bgp group internal neighbor 192.168.0.4set protocols bgp group external type externalset protocols bgp group external export send-directset protocols bgp group external neighbor 172.16.0.5 peer-as 1set protocols bgp group external neighbor 172.16.0.14 peer-as 3set protocols ospf area 0.0.0.0 interface fe-1/2/1.10set protocols ospf area 0.0.0.0 interface lo0.5 passiveset policy-options policy-statement send-direct term 1 from protocol directset policy-options policy-statement send-direct term 1 then acceptset routing-options router-id 192.168.0.5set routing-options autonomous-system 2

Device R6

set interfaces fe-1/2/0 unit 14 description R6->R4set interfaces fe-1/2/0 unit 14 family inet address 172.16.0.10/30set interfaces fe-1/2/1 unit 15 description R6->R7set interfaces fe-1/2/1 unit 15 family inet address 10.0.6.1/30set interfaces lo0 unit 6 family inet address 192.168.0.6/32set protocols bgp group internal type internalset protocols bgp group internal local-address 192.168.0.6set protocols bgp group internal export send-directset protocols bgp group internal neighbor 192.168.0.7set protocols bgp group internal neighbor 192.168.0.8set protocols bgp group external type externalset protocols bgp group external export send-directset protocols bgp group external peer-as 2set protocols bgp group external neighbor 172.16.0.9 peer-as 2set protocols ospf area 0.0.0.0 interface fe-1/2/1.15set protocols ospf area 0.0.0.0 interface lo0.6 passiveset policy-options policy-statement send-direct term 1 from protocol directset policy-options policy-statement send-direct term 1 then acceptset routing-options router-id 192.168.0.6set routing-options autonomous-system 3

Device R7

set interfaces fe-1/2/0 unit 16 description R7->R6set interfaces fe-1/2/0 unit 16 family inet address 10.0.6.2/30set interfaces fe-1/2/1 unit 17 description R7->R8set interfaces fe-1/2/1 unit 17 family inet address 10.0.7.2/30set interfaces lo0 unit 7 family inet address 192.168.0.7/32set protocols bgp group internal type internalset protocols bgp group internal local-address 192.168.0.7set protocols bgp group internal export send-directset protocols bgp group internal neighbor 192.168.0.6set protocols bgp group internal neighbor 192.168.0.8set protocols ospf area 0.0.0.0 interface fe-1/2/0.16set protocols ospf area 0.0.0.0 interface fe-1/2/1.17set protocols ospf area 0.0.0.0 interface lo0.7 passiveset policy-options policy-statement send-direct term 1 from protocol directset policy-options policy-statement send-direct term 1 then acceptset routing-options router-id 192.168.0.7set routing-options autonomous-system 3

Device R8

set interfaces fe-1/2/0 unit 12 description R8->R5set interfaces fe-1/2/0 unit 12 family inet address 172.16.0.14/30set interfaces fe-1/2/1 unit 18 description R8->R7set interfaces fe-1/2/1 unit 18 family inet address 10.0.7.1/30set interfaces lo0 unit 8 family inet address 192.168.0.8/32set protocols bgp group internal type internalset protocols bgp group internal local-address 192.168.0.8set protocols bgp group internal export send-directset protocols bgp group internal neighbor 192.168.0.6set protocols bgp group internal neighbor 192.168.0.7set protocols bgp group external type externalset protocols bgp group external export send-directset protocols bgp group external peer-as 2set protocols bgp group external neighbor 172.16.0.13 peer-as 2set protocols ospf area 0.0.0.0 interface fe-1/2/1.18set protocols ospf area 0.0.0.0 interface lo0.8 passiveset policy-options policy-statement send-direct term 1 from protocol directset policy-options policy-statement send-direct term 1 then acceptset routing-options router-id 192.168.0.8set routing-options autonomous-system 3

Configuring Device R1

Step-by-Step Procedure

The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.

To configure Device R1:

  1. Configure the interfaces.
    [edit interfaces fe-1/2/0 unit 2]user@R1# set description R1->R2user@R1# set family inet address 10.0.0.1/30
    [edit interfaces fe-1/2/1 unit 7]user@R1# set description R1->R4user@R1# set family inet address 172.16.0.1/30
    [edit interfaces lo0 unit 1]user@R1# set family inet address 192.168.0.1/32
  2. Configure IBGP.
    [edit protocols bgp group internal]user@R1# set type internaluser@R1# set local-address 192.168.0.1user@R1# set export send-directuser@R1# set neighbor 192.168.0.2user@R1# set neighbor 192.168.0.3
  3. Configure EBGP.
    [edit protocols bgp group external]user@R1# set type externaluser@R1# set export send-directuser@R1# set peer-as 2user@R1# set neighbor 172.16.0.2
  4. Associate the MED value with the IGP metric.
    [edit protocols bgp group external]user@R1# set metric-out igp delay-med-update

    The default for the MED update is 10 minutes when you include the delay-med-update option. When you exclude the delay-med-update option, the MED update occurs immediately after the IGP metric changes.

  5. (Optional) Configure the update interval for the MED update.
    [edit routing-options]user@R1# set med-igp-update-interval 12

    You can configure the interval from 10 minutes through 600 minutes.

  6. Configure OSPF.
    [edit protocols ospf area 0.0.0.0]user@R1# set interface fe-1/2/0.2 metric 600user@R1# set interface lo0.1 passive

    The metric statement is used here to demonstrate what happens when the IGP metric changes.

  7. Configure a policy that accepts direct routes.

    Other useful options for this scenario might be to accept routes learned through OSPF or local routes.

    [edit policy-options policy-statement send-direct term 1]user@R1# set from protocol directuser@R1# set then accept
  8. Configure the router ID and autonomous system (AS) number.
    [edit routing-options]user@R1# set router-id 192.168.0.1user@R1# set autonomous-system 1

Results

From configuration mode, confirm your configuration by entering the show interfaces, show policy-options, show protocols, and show routing-options commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.

user@R1# show interfaces
fe-1/2/0 {unit 2 {description R1->R2;family inet {address 10.0.0.1/30;}}}
fe-1/2/1 {unit 7 {description R1->R4;family inet {address 172.16.0.1/30;}}}
lo0 {unit 1 {family inet {address 192.168.0.1/32;}}}
user@R1# show policy-options
policy-statement send-direct {term 1 {from protocol direct;then accept;}}
user@R1# show protocols
bgp {group internal {type internal;local-address 192.168.0.1;export send-direct;neighbor 192.168.0.2;neighbor 192.168.0.3;}group external {type external;metric-out igp delay-med-update;export send-direct;peer-as 2;neighbor 172.16.0.2;}}
ospf {area 0.0.0.0 {interface fe-1/2/0.2 {metric 600;}interface lo0.1 {passive;}}}
user@R1# show routing-optionsmed-igp-update-interval 12;router-id 192.168.0.1;autonomous-system 1;

If you are done configuring the device, enter commit from configuration mode. Repeat the configuration steps on the other devices in the topology, as needed for your network.

Verification

Confirm that the configuration is working properly.

Checking the BGP Advertisements

Purpose

Verify that Device R1 is advertising to Device R4 a BGP MED value that reflects the IGP metric.

Action

From operational mode, enter the show route advertising-protocol bgp command.

user@R1> show route advertising-protocol bgp 172.16.0.2
inet.0: 19 destinations, 33 routes (19 active, 0 holddown, 0 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 10.0.0.0/30             Self                 0                  I
* 172.16.0.0/30           Self                 0                  I
* 172.16.0.4/30           Self                 601                I
* 192.168.0.1/32          Self                 0                  I

Meaning

The 601 value in the MED column shows that the MED value has been updated to reflect the configured OSPF metric.

Verifying That the MED Value Changes When the OSPF Metric Changes

Purpose

Make sure that when you raise the OSPF metric to 700, the MED value is updated to reflect this change.

Action

From configuration mode, enter the set protocols ospf area 0 interface fe-1/2/0.2 metric 700 command.

user@R1# set protocols ospf area 0 interface fe-1/2/0.2 metric 700
user@R1# commit

After waiting 12 minutes (the configured delay period), enter the show route advertising-protocol bgp command from operational mode.

user@R1> show route advertising-protocol bgp 172.16.0.2
inet.0: 19 destinations, 33 routes (19 active, 0 holddown, 0 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 10.0.0.0/30             Self                 0                  I
* 172.16.0.0/30           Self                 0                  I
* 172.16.0.4/30           Self                 701                I
* 192.168.0.1/32          Self                 0                  I

Meaning

The 701 value in the MED column shows that the MED value has been updated to reflect the configured OSPF metric.

Testing the minimum-igp Setting

Purpose

Change the configuration to use the minimum-igp statement instead of the igp statement. When you increase the OSPF metric, the MED value remains unchanged, but when you decrease the OSPF metric, the MED value reflects the new OSPF metric.

Action

From configuration mode, delete the igp statement, add the minimum-igp statement, and increase the OSPF metric.

user@R1# delete protocols bgp group external metric-out igp
user@R1# set protocols bgp group external metric-out minimum-igp
user@R1# set protocols ospf area 0 interface fe-1/2/0.2 metric 800
user@R1# commit

From operational mode, enter the show route advertising-protocol bgp command to make sure that the MED value does not change.

user@R1> show route advertising-protocol bgp 172.16.0.2
inet.0: 19 destinations, 33 routes (19 active, 0 holddown, 0 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 10.0.0.0/30             Self                 0                  I
* 172.16.0.0/30           Self                 0                  I
* 172.16.0.4/30           Self                 701                I
* 192.168.0.1/32          Self                 0                  I

From configuration mode, decrease the OSPF metric.

user@R1# set protocols ospf area 0 interface fe-1/2/0.2 metric 20
user@R1# commit

From operational mode, enter the show route advertising-protocol bgp command to make sure that the MED value does change.

user@R1> show route advertising-protocol bgp 172.16.0.2
inet.0: 19 destinations, 33 routes (19 active, 0 holddown, 0 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 10.0.0.0/30             Self                 0                  I
* 172.16.0.0/30           Self                 0                  I
* 172.16.0.4/30           Self                 21                 I
* 192.168.0.1/32          Self                 0                  I

Meaning

When the minimum-igp statement is configured, the MED value changes only when a shorter path is available.

Published: 2014-07-23