Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

MED

Direct answer

MED (Multi-Exit Discriminator) is a hint to a neighboring AS about which entry point into your AS it should prefer; lower is better. By default it is compared only between paths from the same neighbor AS, and it is weaker than LOCAL_PREF and AS_PATH.

When to use this

Use it when you have two or more links to the same neighbouring AS and want to tell that AS which link to use toward you, or when a MED you receive seems to be ignored.

First 30 seconds

1. MED (metric) is compared only between paths from the same neighbouring AS by default.

2. Lower wins; set outbound with a route-map to influence how a neighbour enters your AS.

3. bgp always-compare-med / bgp bestpath med missing-as-worst change behaviour.

Operational verification

MED set outbound toward the neighbouring AS → neighbour receives the prefix on each link → paths from the same neighbouring AS? (otherwise MED is skipped) → earlier attributes equal → lower MED wins → neighbour's best path → inbound traffic

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Protocol standard + deployed implementation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformProtocol standard · Cisco IOS XE · IOS/IOS XE
Key commandshow ip bgp 198.51.100.0 255.255.255.0
Scope / prerequisiteUse it when you have two or more links to the same neighbouring AS and want to tell that AS which link to use toward yo…
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

7 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 First 30 seconds Verify boundary

Immediate answer: Compare MED only among paths where BGP actually reaches the MED decision point and record which neighboring AS supplied each value.

Verification chain: candidate paths → earlier best-path attributes → neighboring-AS comparison context → MED → later tiebreakers → RIB

Stop condition: Lower MED is not a universal preference rule across unrelated paths; earlier attributes and comparison scope can make MED irrelevant.

Step 2 Operational verification and known-good state Verify boundary
show ip bgp 198.51.100.0 255.255.255.0
show running-config | include med
show route-map MED-PRIMARY

Run the first on the router that has to choose: metric on each path is the MED it received. The second shows which of the MED options are configured on that router. The third, on the sender, shows the clause that sets the value. As with other outbound policy, verify the result on the receiving side — the sender's advertised-routes view may not reflect values set by an outbound route-map.

Known-good: the receiver sees the intended MED on each link, the paths are from the same neighbouring AS and equal on earlier attributes, and the lower MED is best.

Step 3 Verification and output interpretation Verify boundary

Inspect MED values on competing paths for the exact prefix and confirm they were learned from contexts where MED is actually compared. Read the best-path reason rather than assuming the lower number must win. If influencing a neighboring AS, remote visibility is the strongest validation; the local advertisement shows the value was sent, not that the neighbor honored it.

Step 4 Step-by-step troubleshooting Narrow the fault

2. Walk this chain: candidate paths → earlier best-path attributes → neighboring-AS comparison context → MED → later tiebreakers → RIB.

Boundary rule: Lower MED is not a universal preference rule across unrelated paths; earlier attributes and comparison scope can make MED irrelevant.

Step 5 Verification & troubleshooting Narrow the fault

1. Do both paths come from the same neighbouring AS? Compare the first AS number in each path.

2. Are the earlier attributes equal on the receiving router — LOCAL_PREF, AS_PATH length, ORIGIN?

3. Which metric values did the receiver actually get?

4. Check the receiver for always-compare-med, deterministic-med and missing-as-worst.

5. Check the outbound route-map on the sender and run clear ip bgp <neighbour> soft out.

Step 6 Failure signatures and troubleshooting branches Narrow the fault
  • MED seems ignored. The paths come from different neighbouring ASes, or an earlier attribute already decided — providers often set LOCAL_PREF themselves.
  • A route without any MED wins. Missing counts as 0, the best value.
  • The best path changes after a session reset although nothing else changed. bgp deterministic-med is not configured.
  • MED is unexpectedly large. The route was injected from the IGP and inherited the IGP metric.
  • A network two ASes away does not see your MED. It is not carried beyond the neighbouring AS.
  • The provider does not honour MED at all. Use its documented communities or AS_PATH prepending instead.
Step 7 When the problem is really fixed Narrow the fault
  • The receiving router shows the intended MED on each link.
  • The paths compared are from the same neighbouring AS and equal on earlier attributes.
  • The path with the lower MED is best there.
  • Inbound traffic arrives on the intended link (interface counters, traceroute from outside).
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Command lookup Jump straight to Cisco syntax
Key points

Lower wins. MED is compared only between paths from the same neighbouring AS unless bgp always-compare-med is set, and only after Weight, LOCAL_PREF, AS_PATH and ORIGIN are equal. It is a request to the neighbour, who can override it with LOCAL_PREF. A missing MED counts as 0 (best) unless bgp bestpath med missing-as-worst is configured.

Key checks

show ip bgp <prefix> on the router that chooses → metric is the MED on each path. show running-config | include med → always-compare-med, deterministic-med, missing-as-worst. Confirm the MED you send on the receiving side.

ReferenceWhat it is2 sections · depth on demand

BGP scope — internal and external paths

MED is a lower-is-preferred ingress hint conveyed to a neighboring AS. A MED learned through eBGP can be distributed inside that receiving AS via iBGP; its presence is not exclusive to an eBGP session. It is not normally propagated onward to a third AS. Cisco normally compares MED among paths from the same neighboring AS unless configuration changes the comparison scope. Deterministic MED and always-compare-med are different controls; inspect the effective settings before explaining a selection.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

What it is

MED (multi-exit discriminator, displayed as metric) is a number you attach to routes you advertise to a neighbouring AS to suggest which of several links it should use to reach you. Lower is preferred.

ReferenceWhy it matters1 section · depth on demand

Why it matters

MED is the one attribute designed as a hint to the neighbour, which makes it useful when you have two or more links to the same provider. It is also weak: it comes late in the decision, it is compared only between paths from the same neighbouring AS, and the neighbour is free to override it. Knowing those limits explains almost every case of "MED does not work".

ReferenceImportant terms & boundaries6 sections · depth on demand

Key points

  • Lower wins. Shown as metric in show ip bgp.
  • Compared only between paths whose neighbouring AS is the same, unless bgp always-compare-med is configured.
  • Checked after Weight, LOCAL_PREF, local origination, AS_PATH length and ORIGIN.
  • Sent to the eBGP neighbour and carried inside that AS; it is not passed on to a third AS.
  • A route without MED is treated as 0 — the best value — unless bgp bestpath med missing-as-worst is set.
  • bgp deterministic-med makes the result independent of the order paths arrived in; use it consistently across the AS.
  • Set it outbound with set metric. Routes injected from the IGP carry the IGP metric as MED by default.

In depth

MED suggests to a neighbouring AS which entry point to use

MED (multi-exit discriminator) is step 6 in Cisco's best path order. Lower wins. It's sent to an eBGP neighbour to influence which of several links that neighbour uses to send traffic in.

Documented comparison rules

RuleDetail from Cisco's document
Default comparison scopeOnly between paths from the same neighbouring AS
bgp always-compare-medCompare MED across different ASes; must be enabled on every router in the AS
bgp deterministic-medGroup paths per neighbouring AS before comparing, so the result doesn't depend on arrival order
Missing MEDTreated as 0 (best), unless bgp bestpath med missing-as-worst makes it the worst value
R1(config)# route-map MED-LINK1 permit 10
R1(config-route-map)# set metric 50
R1(config)# route-map MED-LINK2 permit 10
R1(config-route-map)# set metric 150
R1(config)# router bgp 64500
R1(config-router)# neighbor 192.0.2.1 route-map MED-LINK1 out
R1(config-router)# neighbor 192.0.2.13 route-map MED-LINK2 out
ISP# show ip bgp 198.51.100.0/24
  64500
    192.0.2.2 from 192.0.2.2 (10.0.0.1)
      Origin IGP, metric 50, localpref 100, valid, external, best
  64500
    192.0.2.14 from 192.0.2.14 (10.0.0.3)
      Origin IGP, metric 150, localpref 100, valid, external

In show ip bgp, MED is shown as metric.

Limits

LimitConsequence
Step 6 comes after LOCAL_PREF and AS_PATHThe neighbour's own policy overrides MED
Many providers ignore or reset customer MEDCheck their routing policy documentation
Inconsistent always-compare-medRouting loops or oscillation inside the neighbour's AS

Deterministic MED in practice

Without deterministic-med, the best path can depend on the order in which paths were received. Enable it, together with consistent MED settings, on all routers in the AS.

Documented example, not captured output.

Quick reference

MED (MULTI_EXIT_DISC) is an optional attribute an AS sends to a neighboring AS to suggest which of several links the neighbor should use to enter; lower MED is preferred. By default MED is compared only between paths from the same neighbor AS.

route-map TO-ISP-LINK2 permit 10
 set metric 200
bgp always-compare-med               ! compare across different ASes
bgp bestpath med missing-as-worst

Documented example, not captured output.

MED is checked after LOCAL_PREF and AS_PATH, so the neighbor's own policy can override it.

Mechanics and state ownership

The sender sets MED per neighbour, typically a low value on the link it wants used and a higher one on the backup. The receiving AS carries the values to its own routers and, if the paths are otherwise equal, sends traffic over the link with the lower MED.

The comparison is restricted to paths from the same neighbouring AS because the number only means something within one network's scheme: 50 from one provider and 50 from another are not comparable. bgp always-compare-med removes the restriction and is only sensible when all neighbours have agreed on a common scale.

Without bgp deterministic-med the router compares paths pairwise in the order they were received. When paths from several ASes are mixed, the winner can depend on that order, so the same inputs may give a different best path after a session reset. Deterministic MED first compares paths within each neighbouring AS and then the group winners against each other, which removes the dependency.

State model and selection mechanics

The Multi-Exit Discriminator is an optional non-transitive attribute commonly used when two ASes have multiple interconnections. A router can advertise different MED values for the same prefix on different links so the neighboring AS has a signal for preferred ingress. By default, comparison is commonly constrained to paths learned from the same neighboring AS unless configuration changes the rule. MED is evaluated after several stronger policy attributes, so it is intentionally weaker than LOCAL_PREF.

Limits and common misconceptions

MED is a hint, not a contract. The receiving AS can override it with LOCAL_PREF, Weight, communities or other policy. A lower MED is not globally meaningful across arbitrary providers, and a MED value does not describe latency, cost or link utilization unless the operators deliberately map policy that way.

ReferenceConfiguration & state1 section · depth on demand

Policy and configuration model

Set MED only where both sides understand the policy and where the comparison domain is predictable. Use route policy to scope the value to the intended prefixes and peers rather than applying it globally without design intent. If deterministic or always-compare behavior is changed, document that explicitly because it changes which candidate paths can be compared.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical examples

Configuration & expected output

Concrete examples are shown only when the stored reference contains an actual configuration or output shape for this Topic.

Configuration example

Cisco IOS / IOS XE RFC 4271Ask the neighbouring AS to use the link to 192.0.2.2 as primary and 192.0.2.6 as backup toward this AS

Assumptions: Lab addressing; local AS 65000; both eBGP sessions go to the same neighbouring AS and are Established.

route-map MED-PRIMARY permit 10
 set metric 50
route-map MED-BACKUP permit 10
 set metric 100
!
router bgp 65000
 address-family ipv4 unicast
  neighbor 192.0.2.2 route-map MED-PRIMARY out
  neighbor 192.0.2.6 route-map MED-BACKUP out
!
! then: clear ip bgp * soft out

Expected output

Cisco IOS / IOS XE RFC 4271show ip bgp 198.51.100.0 255.255.255.0

Expected state: Seen from the neighbouring AS: two paths from AS 65000, the one with metric 50 is best.

BGP routing table entry for 198.51.100.0/24
Paths: (2 available, best #1, table default)
  65000
    192.0.2.1 from 192.0.2.1 (1.1.1.1)
      Origin IGP, metric 50, localpref 100, valid, external, best
  65000
    192.0.2.5 from 192.0.2.5 (1.1.1.2)
      Origin IGP, metric 100, localpref 100, valid, external
! Illustrative output, not captured Evidence.
`metric` is the MED. Both paths come from AS 65000 with equal LOCAL_PREF, AS_PATH length and ORIGIN, so MED is compared and 50 beats 100. If the second path came from a different AS, MED would be skipped and a later step would decide.
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docProtocol standard + deployed implementation RFC 4271

Authoritative/upstream documentation reviewed for bounded claims in Routing → BGP → eBGP → MED. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://www.rfc-editor.org/rfc/rfc4271.html · confidence 94%
Embedded reference data

Quick lookup tables

MED · routing reference

Compact path-selection and evidence boundaries for fast lookup.

PropertyMED
DirectionSuggests inbound entry to neighbor
PreferenceLower wins when compared
StrengthLater than LOCAL_PREF/AS_PATH in common order
GuaranteeNone; remote policy can override

MED operational reference

Topic-specific bounded interpretation: known-good BGP state, suspicious signatures and the next technical proof boundary.

BoundaryKnown-good for MEDSuspicious signatureNext proof
Session/inputCorrect peer, AF and prefix contextTransport, FSM or prefix eligibility disagreesPeer detail and exact prefix
Attribute/policythe Multi-Exit Discriminator as a neighboring-AS ingress hint, with lower values generally preferred where comparison rules make the candidates eligible to be compared matches intended policyMED changed on a route but best path did not move because an earlier attribute decided first, values being compared across a scope where the platform does not compare them by default, inbound policy overwriting the received MED, missing attribute behavior being misunderstood, or a lower-MED path selected while its downstream forwarding is unhealthyCompare candidate paths and policy
Route/forwardingExpected best path reaches RIB/FIBBGP state exists but installed path disagreesRIB/FIB/CEF and next-hop proof
ClosureOriginal test passes for explained reasonSymptom moved, was bypassed or state was forcedRegression/failover test
Confirmation

Confirm action

Continue?