How to Influence Inbound and Outbound BGP Traffic: LOCAL_PREF, Prepending and MED

How do you influence inbound and outbound BGP traffic? Use LOCAL_PREF inside your AS to choose the preferred exit for traffic leaving your network; influence traffic entering your network by changing the routes you advertise, for example with AS-path prepending or MED where appropriate.[1][2] The key interview distinction is that you control your own routing policy, but another AS decides how it reaches your prefixes.[2]

First separate packet direction from policy direction

An inbound BGP policy processes routes received from a neighbor; those routes describe destinations your packets can travel toward.[2] An outbound BGP policy processes routes advertised to a neighbor; those advertisements help that neighbor choose how to reach the destinations you announce.[2] Consequently, an import policy can change outbound traffic, while an export policy can influence inbound traffic.[2]

Use this memory aid: learn routes to choose your exit; advertise routes to influence your entrance.

Which BGP attribute should you use?

Objective Usual tool Where to apply it Important limitation
Prefer one exit across your AS Higher LOCAL_PREF Import policy on routes learned at your border Shared through iBGP; not normally sent to external peers.[2]
Prefer one exit on one Cisco router Higher weight Local policy on that router Cisco-specific and not propagated to other routers.[1]
Make one advertised path less attractive AS-path prepending Export policy toward the less-preferred upstream Remote preference can beat AS-path length.[1][2]
Suggest an entry link to the same neighboring AS Lower MED on the preferred announcement Export policy toward that neighbor Normally compared for paths from the same neighboring AS, after earlier criteria.[1][2]

These are different tools, not interchangeable names for a single priority value. In Cisco's documented normal selection order, weight precedes LOCAL_PREF, and LOCAL_PREF precedes AS-path length and MED.[1] Do not claim that a low MED or a short AS path always wins.[1]

A dual-provider example

Consider an illustrative lab: your AS 65010 connects to Provider A, AS 65020, and Provider B, AS 65030. Your advertised lab prefix is 203.0.113.0/24; a remote lab destination is 198.51.100.0/24. All addresses and ASNs here are for an isolated example, not a real Internet deployment.

The design goal is to prefer A in both directions and retain B as a backup. Assume valid routes, reachable next hops, working iBGP between your border routers, and no competing weight or special best-path policy.

Outbound: choose A with LOCAL_PREF

Set LOCAL_PREF 200 on the accepted route to 198.51.100.0/24 learned from A and LOCAL_PREF 100 on the equivalent route learned from B. Under those assumptions, A wins because the higher LOCAL_PREF is preferred and is carried to internal peers.[1][2] Even if B has a shorter AS path, the higher LOCAL_PREF through A wins at the earlier comparison step.[1]

Illustrative route-processing flow, not router output:
A advertises remote destination -> import policy sets LOCAL_PREF 200
B advertises same destination   -> import policy sets LOCAL_PREF 100
             -> distribute routes through iBGP
             -> choose valid higher-preference path
             -> forward packets toward A

The BGP session endpoint is not necessarily the forwarding next hop: check NEXT_HOP resolution as well as the preferred route.[2] A route whose next hop is unreachable is not an eligible best-path candidate in the documented Cisco algorithm.[1]

Inbound: make the B announcement less attractive

Advertise your own lab prefix to both providers, but add extra copies of your own AS number to its announcement toward B. BGP permits repeated occurrences of the local AS in AS_PATH, and shorter AS paths are preferred when earlier selection criteria tie.[1][2]

Illustrative export intent, not platform configuration:
To A: permit only approved owned prefixes; no additional prepend
To B: permit only approved owned prefixes; prepend own AS twice
To either provider: reject all other exports

This is an influence, not a guarantee: a remote network with a higher local preference for its route through B can still choose B despite the longer AS path.[1] Verify the received path remotely rather than assuming how many AS occurrences a particular CLI displays before or after export processing.

When MED fits better

If the two links connect to the same provider AS, advertising a lower MED on the preferred link can express your entry-point preference.[2] MED is optional and non-transitive; a MED received from one neighboring AS is not propagated onward to another neighboring AS.[2] Cisco normally compares MED for paths from the same neighboring AS, so do not present MED as a universal two-independent-provider steering mechanism.[1] Agree the policy with the provider and confirm its observed behavior before relying on it.

Verification checklist: prove routes and traffic separately

Use the following as a proposed change checklist, not a record of an executed router lab.

  1. Record the baseline. Save the existing import/export policy and inspect the exact destination prefix on both border routers.
  2. Check eligibility. Confirm the neighbor is Established, the route is accepted, and its NEXT_HOP is reachable; an unreachable next hop disqualifies a path.[1]
  3. Inspect the attribute that should change. Check LOCAL_PREF locally and on an internal peer for outbound steering; inspect the advertised AS path or MED and obtain the neighbor's received view for inbound steering.
  4. Inspect installed forwarding. Check the routing table and forwarding entry for an actual test destination, not just the BGP best marker.
  5. Test both directions. Request measurements from the remote side as well as running a local test. Do not treat one outbound traceroute as proof of the reverse path.
  6. Check backup behavior in a lab or approved window. Withdraw the preferred test route or isolate the preferred lab link, confirm B is usable, then restore the baseline.
  7. Define rollback. Revert the scoped policy if approved-prefix visibility, forwarding, or application checks fail. Avoid a broad session reset merely to test an attribute change.

Illustrative Cisco IOS/IOS XE inspection commands follow; confirm command syntax and address-family context on your software release. These are commands to run, not fabricated results.

show ip bgp summary
show ip bgp 198.51.100.0/24
show ip route 198.51.100.1
show ip cef 198.51.100.1
show ip bgp neighbors 192.0.2.2 advertised-routes
show route-map
show ip prefix-list

For inbound steering, obtain a provider looking-glass or received-route view and a remote traffic test. Your own advertised-routes view alone cannot prove the remote AS's final best-path choice.

Common pitfalls and troubleshooting clues

Symptom or mistake What to inspect next
LOCAL_PREF changed but the router still chooses B Look for a higher Cisco weight, an invalid A path, or a policy matching the wrong prefix.[1]
Only one router changes exit Check whether you changed local-only weight instead of AS-distributed LOCAL_PREF, then inspect iBGP route visibility.[1][2]
Prepending does not change incoming traffic Ask for the remote best-path reason: remote LOCAL_PREF can override AS-path length.[1]
MED differs but has no apparent effect Check neighboring AS identity, earlier attributes, and any MED comparison overrides.[1]
Route changes but the application does not behave as expected Check the actual destination, VRF, forwarding entry, and traffic observations before changing more attributes.
Engineer tries to send LOCAL_PREF to an ordinary ISP peer LOCAL_PREF is not sent to normal eBGP peers; confederations are the protocol exception.[2]

Keep the export allowlist explicit. Do not turn a narrow traffic-engineering example into permission to advertise every route learned from another provider.

A short interview answer

“I separate packet direction from BGP policy direction. For outbound traffic, I usually set higher LOCAL_PREF on routes learned through my preferred exit and distribute that preference through iBGP.[2] For inbound traffic, I can prepend my own AS toward a less-preferred upstream, or use MED for appropriate multiple links to the same neighboring AS.[1][2] Neither forces another AS to follow my preference: its earlier policy decisions can win.[1] I verify the route attributes, installed forwarding, and traffic from both sides, and test the backup path before calling the change complete.”

Related reading

Summary

LOCAL_PREF chooses your exit; prepending and appropriately scoped MED try to influence another AS's choice of entrance.[1][2] Preparing for a network engineering interview? Sketch a dual-provider network and explain which routes you would modify, in which policy direction, and what evidence would prove the result.

Sources

Comments

Popular posts from this blog

BGP Neighbor States

Reason legend in show ip ospf statistics