set med [value]
Sets the MULTI_EXIT_DISC (MED) attribute for BGP routes in a route policy.
Overview
The 'set med' command in Cisco IOS-XR is used within a route policy to set the MULTI_EXIT_DISC (MED) attribute for BGP routes. The MED attribute is a metric that influences inbound traffic from a neighboring AS. It is exchanged between ASes and is used to discriminate between multiple entry points into the same AS. A lower MED value is preferred. This command is typically used in route policies applied to BGP neighbors or route-maps to manipulate the MED attribute based on various conditions such as prefix, community, or AS-path. In IOS-XR, the MED value can be set to a fixed number or derived from a variable. The command is part of the route policy configuration mode and is used in conjunction with other set commands to modify BGP attributes. Understanding MED is crucial for traffic engineering and load balancing in multi-homed environments. The command does not produce output; verification is done via 'show bgp' commands.
set med [value]When to Use This Command
- Influencing inbound traffic from a multi-homed AS by advertising a lower MED for preferred paths.
- Implementing traffic engineering by adjusting MED values based on BGP community or AS-path.
- Setting MED to IGP metric to prefer routes with lower interior cost.
- Using MED to differentiate between multiple exit points from the same AS.
Parameters
| Parameter | Syntax | Description |
|---|---|---|
| value | value | The MED value to set. It can be a number from 0 to 4294967295, or a reference to a variable that holds a numeric value. The value is used as the MED attribute in BGP updates. |
Command Examples
Set MED to a fixed value
set med 50Sets the MED attribute to 50 for all routes matching the route policy conditions.
Set MED using a variable
set med 100Sets the MED attribute to 100. The value can be a number or a reference to a variable.
Understanding the Output
The 'set med' command does not produce direct output; it modifies the BGP route's MED attribute within a route policy. To verify the effect, use 'show bgp' commands to inspect the MED value for specific prefixes. A healthy MED value is typically a positive integer (0-4294967295). Problem values might be missing (no MED) or inconsistent with network policy.
Configuration Scenarios
Setting MED based on prefix
A service provider wants to prefer a specific prefix from a customer via a specific link.
Topology
AS 100 (Provider) --- Link1 --- AS 200 (Customer)
--- Link2 --- AS 200 (Customer)Steps
- 1.Create a route policy that matches the prefix and sets MED to 50.
- 2.Apply the policy to the BGP neighbor on Link1.
route-policy SET-MED
if destination in (10.0.0.0/8) then
set med 50
endif
end-policy
!
router bgp 100
neighbor 192.168.1.1
address-family ipv4 unicast
route-policy SET-MED outVerify: Use 'show bgp 10.0.0.0/8' to verify MED is 50 on routes received from AS 200 via Link1.
Watch out: Ensure the route policy is applied in the outbound direction to affect routes sent to the neighbor.
Troubleshooting with This Command
When troubleshooting MED issues, first verify that the route policy is correctly applied using 'show running-config router bgp'. Use 'show bgp prefix' to check the MED value of specific routes. If MED is not being set as expected, check the route policy conditions and ensure the policy is attached to the correct neighbor and address-family. Use 'show bgp neighbor' to see if the policy is active. Also, verify that the MED value is within the valid range. If MED is not being considered in best path selection, check the 'bgp bestpath med always' configuration, which allows MED comparison even if routes come from different ASes. Use 'show bgp bestpath' to understand the path selection process.
CCNA Exam Tips
Remember that MED is a 4-byte unsigned integer (0-4294967295).
MED is exchanged between ASes; lower MED is preferred.
MED is reset when the route leaves the AS (unless 'bgp bestpath med always' is configured).
Common Mistakes
Setting MED to a value outside the valid range (0-4294967295).
Forgetting that MED is only considered when comparing routes from the same neighboring AS.
Using 'set med' without proper route policy conditions, affecting unintended routes.
Platform Notes
In Cisco IOS-XR, the 'set med' command is used within route-policy configuration, which is different from IOS where it is used in route-map. IOS-XR uses a more structured policy language. The command syntax is 'set med value' where value can be a number or a variable. There is no 'set metric' equivalent; MED is set directly. In IOS, the equivalent is 'set metric' in route-map. IOS-XR also supports 'set med igp-cost' to set MED to the IGP metric, but that is a separate command. Version differences: In earlier IOS-XR versions, the command might have been 'set med' with different syntax; always check the specific version documentation.
Practice for the CCNA 200-301
Test your knowledge with hundreds of CCNA practice questions covering all exam domains.
Practice CCNA Questions