Configuring the MED in BGP Updates
The BGP multiple exit discriminator (MED, or MULTI_EXIT_DISC) is an optional path attribute that can be included in BGP update messages. This attribute is used on external BGP links (that is, on inter-AS links) to select among multiple exit points to a neighboring AS. The MED attribute has a value that is referred to as a metric. If all other factors in determining an exit point are equal, the exit point with the lowest metric is preferred.
If a MED is received over an external BGP link, it is propagated over internal links to other BGP systems within the AS.
BGP update messages include a MED metric if the route was learned from BGP and already had a MED metric associated with it, or if you configure the MED metric in the configuration file in one of the following ways:
A MED metric is advertised with a route according to the following general rules:
- A more specific metric overrides a less specific metric. That is, a group-specific metric overrides a global BGP metric and a peer-specific metric overrides a global BGP or group-specific metric.
- A metric defined with routing policy overrides a metric defined with the metric-out statement.
- If any metric is defined, it overrides a metric received in a route.
- If the received route does not have an associated MED metric, and if you do not explicitly configure a metric value, no metric is advertised. When you do not explicitly configure a metric value, the MED is equivalent to zero (0) when advertising an active route.
For a description of the algorithm used to determine the active path, see How the Active Route Is Determined.
Defining a MED Metric Directly
To directly configure a MED metric to advertise in BGP update messages, include the metric-out statement:
For a list of hierarchy levels at which you can include this statement, see the statement summary section for this statement.
metric is the primary metric on all routes sent to peers. It can be a value in the range from 0 through 4,294,967,295 (232 – 1).
Specify minimum-igp to set the metric to the minimum metric value calculated in the IGP to get to the BGP next hop. If a newly calculated metric is greater than the minimum metric value, the metric value remains unchanged. If a newly calculated metric is lower, the metric value is lowered to that value.
Specify igp to set the metric to the most recent metric value calculated in the IGP to get to the BGP next hop.
In Junos OS Release 9.0 and later, you can also specify that a BGP group or peer configured with the metric-out igp statement delay sending MED updates when the MED value increases. Include the delay-med-update statement when you configure the igp statement. The default interval to delay sending updates unless the MED is lower or another attribute associated with the route has changed is 10 minutes. Include the med-igp-update-interval minutes statement at the [edit routing-options] hierarchy level to modify the default interval. For information, see Delaying Updates of the MED Path Attribute for BGP.
Specify a value for offset to increase or decrease the metric that is used from the metric value calculated in the IGP. The metric value is offset by the value specified. The metric calculated in the IGP (by specifying either igp or igp-minimum) is increased if the offset value is positive. The metric calculated in the IGP (by specifying either igp or igp-minimum) is decreased if the offset value is negative.
offset can be a value in the range from –231 through 231 – 1. Note that the adjusted metric can never go below 0 or above 232 – 1.
Using Routing Policy to Define a MED Metric
To use routing policy to define a MED metric to advertise, define the routing policy by including the policy-statement statement at the [edit policy-options] hierarchy level, and then apply the filter by including the import and export statements when configuring BGP.
When defining the routing policy filter, include an action that specifies the desired metric value:
For information about defining routing policy, see the Junos Policy Framework Configuration Guide. For information about applying filters in BGP, see Applying Policies to BGP Routes.
Examples: Configuring the MED Metric
Set the MED metric to 20 for all routes advertised in BGP update messages except for those sent to the peer system 192.168.0.1; the MED for this peer is 10:
Set the MED metric to 20 for all routes from a particular community:
