Skip to content
LinkState
Go back

MED surprises across inconsistent neighbor groups

Introduction to BGP MED

Understanding MED Basics

The Multi-Exit Discriminator (MED) is a BGP attribute used to influence the best path selection process. It is a metric that indicates the preferred exit point from an autonomous system (AS) to a neighboring AS. A lower MED value is preferred, as it indicates a more desirable path. MED is often used in scenarios where multiple exit points are available, and the goal is to select the most optimal one.

MED and Route Selection

In BGP, the best path selection process involves evaluating multiple attributes, including MED. The process is as follows:

  1. Weight: The highest weight is preferred.
  2. Local Preference: The highest local preference is preferred.
  3. AS Path Length: The shortest AS path is preferred.
  4. Origin: Routes with an origin of IGP are preferred over those with an origin of EGP or incomplete.
  5. MED: The lowest MED is preferred.
  6. eBGP over iBGP: eBGP routes are preferred over iBGP routes.
  7. Lowest IGP Metric: The route with the lowest IGP metric to the BGP next hop is preferred.
  8. Router ID: The route with the lowest router ID is preferred. Understanding the role of MED in this process is crucial for troubleshooting and optimizing BGP routing decisions.

Troubleshooting Lower MED Loss

Identifying the Issue

A common complaint in BGP routing is when a route with a lower MED value is not selected as the best path. This can lead to suboptimal routing decisions and potential network performance issues. Identifying the root cause of this issue requires a systematic approach to analyzing BGP routing decisions.

Gathering Information

To troubleshoot a lower MED loss, gather the following information:

Analyzing BGP Tables

Analyzing BGP tables involves checking the attributes of the routes in question, including the MED value, AS path, origin, and local preference. Use commands like show ip bgp or show bgp ipv6 unicast to display the BGP table and identify the best path selected for each prefix.

Comparison Scope and MED

Understanding Comparison Scope

Comparison scope refers to the set of routes that are considered comparable during the best path selection process. Routes are only compared if they have the same destination prefix and are from the same AS or have the same AS path length if the routes are from different ASes.

Impact on MED Evaluation

The comparison scope affects how MED is evaluated. If two routes have different AS paths or are from different ASes, their MED values might not be directly comparable. Understanding the comparison scope is crucial for predicting how MED will influence the best path selection.

Configuring Comparison Scope

While the comparison scope is primarily determined by BGP’s inherent behavior, configurations such as route filtering, aggregation, or manipulation of BGP attributes can indirectly influence the comparison scope. For example, using bgp bestpath as-path ignore can alter how AS path length influences the comparison.

Deterministic MED Behavior

MED Calculation

MED is calculated based on the IGP metric to the BGP next hop. Lower MED values indicate a shorter path to the destination.

MED and Route Reflection

In route reflection, the reflector adds its own MED value to the reflected routes. This can affect the best path selection if the reflected routes have different MED values.

Examples of Deterministic MED

Consider a scenario where two routers, R1 and R2, advertise the same prefix with different MED values. If R1 has a MED of 10 and R2 has a MED of 20, and all other attributes are equal, the route from R1 will be preferred due to its lower MED.

Missing AS Grouping and MED

AS Grouping Concepts

AS grouping refers to the concept of treating multiple ASes as a single entity for certain BGP operations. This can affect how MED is evaluated, especially in scenarios involving route reflection or confederations.

Effects of Missing AS Grouping

Missing AS grouping can lead to inconsistent MED evaluation, potentially causing routes with lower MED values to be overlooked. This is because the BGP best path selection process may not correctly account for the relationships between ASes without proper grouping.

Configuring AS Grouping for MED

Configuring AS grouping involves setting up BGP confederations or using route maps to manipulate BGP attributes based on AS numbers. For example, using bgp confederation peers can help in managing AS relationships and thus influence MED evaluation.

Earlier Tie-Breakers and MED

Understanding BGP Tie-Breakers

BGP tie-breakers are the criteria used to select the best path when multiple routes have the same attributes. These include weight, local preference, AS path length, origin, MED, and others.

Impact of Earlier Tie-Breakers on MED

Earlier tie-breakers can override the influence of MED on the best path selection. For instance, if two routes differ in local preference, the route with the higher local preference will be chosen, regardless of the MED value.

Examples of Earlier Tie-Breakers Winning

Consider a scenario where two routes have the same MED but differ in AS path length. The route with the shorter AS path will be preferred, even if the other route has a slightly lower MED value.

Code and CLI Examples

Configuring MED with Cisco IOS

To configure MED on a Cisco IOS router, use the neighbor command under the BGP configuration mode:

router bgp 100
 neighbor 10.0.0.1 route-map SET_MED out

And define the route map:

route-map SET_MED permit 10
 set metric 50

Configuring MED with Juniper Junos

On a Juniper Junos device, MED can be configured using the metric statement under a policy:

policy-statement SET_MED {
    term 1 {
        from protocol bgp;
        then {
            metric 50;
        }
    }
}

Apply this policy to a neighbor:

protocols bgp group EXTERNAL {
    neighbor 10.0.0.1 {
        policy output SET_MED;
    }
}

Verifying MED with BGP Commands

Use show ip bgp or show bgp ipv6 unicast to verify the MED value of routes:

show ip bgp 10.0.0.0/8

This command displays the BGP table entry for the specified prefix, including the MED value.

Scaling Limitations of MED

MED and Network Size

As the network size increases, the complexity of BGP routing decisions also increases. MED can become less effective in influencing the best path selection due to the sheer number of routes and AS paths involved.

MED and Route Flap Dampening

Route flap dampening can suppress routes that are experiencing instability, potentially affecting how MED influences the best path selection. If a route with a lower MED is being dampened, it may not be selected as the best path.

Optimizing MED for Large Networks

To optimize MED for large networks, consider using techniques such as route aggregation, community tagging, and careful planning of AS relationships and BGP policies.

Advanced MED Scenarios

MED and MPLS VPNs

In MPLS VPN environments, MED can be used to influence the best path selection for VPN routes. However, the use of route targets and VPNv4 routes can add complexity to MED evaluation.

MED and BGP Confederations

BGP confederations involve dividing a large AS into smaller sub-ASes. MED can be used within confederations to influence the best path selection, but careful planning is required to ensure consistent MED evaluation across sub-ASes.

MED and Route Servers

Route servers can be used to manage and distribute routes within an AS. MED can be used to influence the best path selection on route servers, but considerations such as route server placement and configuration are crucial.

Best Practices for MED Configuration

Designing MED Policies

When designing MED policies, consider the network topology, AS relationships, and routing requirements. Use route maps and community tags to manipulate MED values based on specific conditions.

Implementing MED Changes

Implement MED changes carefully, as they can affect network routing and performance. Use change management processes to test and validate MED changes before deploying them to production networks.

Monitoring and Troubleshooting MED

Regularly monitor BGP routing decisions and MED values to ensure they align with intended routing policies. Use tools such as show ip bgp and debug ip bgp to troubleshoot MED-related issues.

Case Studies and Real-World Examples

MED in Service Provider Networks

In service provider networks, MED is often used to manage traffic flow and optimize routing decisions. For example, a service provider might use MED to prefer routes through a specific AS or to avoid certain ASes.

MED in Enterprise Networks

In enterprise networks, MED can be used to optimize routing decisions and ensure reliable connectivity to critical resources. For instance, an enterprise might use MED to prefer routes through a primary ISP over a backup ISP.

MED in Data Center Environments

In data center environments, MED can be used to manage traffic flow and optimize routing decisions for cloud and virtualized services. For example, a data center might use MED to prefer routes through a specific ToR switch or to avoid certain network segments.

Future of MED and BGP Routing

Emerging trends such as SDN, NFV, and 5G networks are expected to influence BGP routing and MED evaluation. These trends may introduce new requirements and challenges for MED configuration and optimization.

Impact of SDN and NFV on MED

SDN and NFV can potentially simplify MED configuration and optimization by providing more centralized and programmable control over network routing decisions. However, they also introduce new complexities and requirements for MED evaluation.

Evolution of MED in Modern Networks

As modern networks continue to evolve, MED will remain an important attribute for influencing BGP routing decisions. However, its role and significance may change as new technologies and trends emerge. Network operators must stay adaptable and knowledgeable about MED and BGP routing to ensure optimal network performance and reliability.


Share this post on:

Previous Post
IPv6 link-local recursion after an interface flap
Next Post
Route Reflector Restarts and Path Hunting Waves