Skip to content
7LayerX

Routing / Field note

BGP traffic engineering: choose an exit and influence an entry

Use Local Preference, AS_PATH, and MED to guide BGP traffic while understanding what each network controls.

7LayerX Editorialupdated 4 min readBGP

Traffic engineering means guiding traffic toward a route that fits the network's needs. A team may prefer one provider for lower cost, keep another as backup, or ask a neighbor to use a certain link.

BGP offers useful policy tools, but each AS runs its own policy. A change in your network can influence a neighbor; it cannot force the neighbor to follow your choice.

Start with traffic direction

From your AS's point of view:

  • Outbound traffic leaves your network. Your routers choose the next hop for those packets.
  • Inbound traffic enters your network. Other ASes choose which route to send toward your prefixes.

The place where you apply a policy matters. An inbound policy changes routes as your router receives them, which can change your outbound path. An outbound policy changes how your router advertises routes, which may influence a neighbor's inbound choice.

Choose your own exit with Local Preference

Local Preference tells routers in one AS which exit they should prefer. A higher value wins when routes reach the Local Preference comparison. In the shared simulator topology, Corp-X (AS 64531) receives Path A from ISP-B (AS 64520) and Path B from ISP-C (AS 64540). Both start at 100. Setting Path B to 200 makes Corp-X prefer the ISP-C exit, before it compares later attributes.

ip prefix-list LAB-DESTINATION seq 5 permit 192.0.2.0/24
route-map PREFER-ISP-C permit 10
 match ip address prefix-list LAB-DESTINATION
 set local-preference 200
!
router bgp 64531
 neighbor 10.0.4.1 route-map PREFER-ISP-C in

This Cisco IOS-XE example applies the policy to the route received from ISP-C router C1 at 10.0.4.1. A route map can deny routes that do not match a permit entry. If the neighbor sends other routes, add the correct approved policy before using this pattern. Review the effect in a lab first.

Influence how another AS enters your network

Your neighbor makes its own best-path choice, but you can send policy hints with your advertisements.

AS_PATH prepending

An AS can add its own AS number more than once when it advertises a route. This makes the path appear longer to some neighbors. They may then choose a different route. In the simulator, Path A runs through ISP-B AS 64520 and Path B through ISP-C AS 64540. Prepending AS 64512 on the ISP-A-to-ISP-B advertisement makes Path A appear longer to Corp-X. A neighbor's Local Preference or other policy can still take priority, so prepending is not a promise about the final path.

ip prefix-list LAB-DESTINATION seq 5 permit 192.0.2.0/24
route-map PREPEND-TO-ISP-B permit 10
 match ip address prefix-list LAB-DESTINATION
 set as-path prepend 64512 64512
!
router bgp 64512
 neighbor 10.0.2.1 route-map PREPEND-TO-ISP-B out

Apply the outbound policy on ISP-A router A1 toward ISP-B router B1 (10.0.2.1). The simulator's AS_PATH preset models this change on Path A.

MED

MED is a hint that can suggest which entry point a neighboring AS should use to reach your network. A lower MED is commonly preferred when comparing routes learned from the same neighboring AS. The other network chooses whether and how to compare it. In the simulator, Path A arrives from ISP-B AS 64520 and Path B from ISP-C AS 64540, so the MED preset enables an explicit cross-AS comparison. Real routers often do not compare those values by default.

ip prefix-list LAB-DESTINATION seq 5 permit 192.0.2.0/24
route-map MED-TO-ISP-B permit 10
 match ip address prefix-list LAB-DESTINATION
 set metric 50
!
route-map MED-TO-ISP-C permit 10
 match ip address prefix-list LAB-DESTINATION
 set metric 10
!
! Add each neighbor policy on the matching ISP-A router.
! On ISP-A A1, which peers with ISP-B B1:
router bgp 64512
 neighbor 10.0.2.1 route-map MED-TO-ISP-B out
!
! On ISP-A A2, which peers with ISP-C C1:
router bgp 64512
 neighbor 10.0.4.1 route-map MED-TO-ISP-C out

This shows the Cisco IOS-XE route-map form. Configure each neighbor on its matching ISP-A router. Confirm the exact command and MED comparison behavior on your router. Do not assume Corp-X or another neighbor compares MED from different ASes unless its policy says it does.

A safe change process

  1. Write down the prefix and traffic direction you want to change.
  2. Check current routes, attributes, and advertised routes.
  3. Apply a narrow policy to a test prefix or lab neighbor.
  4. Check the route received by your router and, when possible, the neighbor's view.
  5. Confirm forwarding and keep a rollback plan ready.
show ip bgp 192.0.2.0/24
show ip bgp neighbors 10.0.2.1 routes
show ip bgp neighbors 10.0.4.1 routes
show ip route 192.0.2.0

Command names vary by platform. Check the relevant command reference before making a live network change.

Common questions about BGP traffic engineering

Quick answers about exit paths, inbound traffic, and policy limits.

3 answers

Does Local Preference change inbound traffic?

Local Preference guides route choice inside your own AS, so it mainly changes outbound traffic. AS_PATH prepending, MED, and provider communities may influence inbound traffic, but the other AS controls its own routes.

Is AS_PATH prepending guaranteed to move traffic?

No. A neighbor may prefer its own Local Preference or use another policy before it considers AS_PATH length.

Should I change MED on all routes?

No. Start with the prefixes and neighbor where the value has a clear purpose. Confirm the neighbor's policy and MED comparison behavior first.

Continue with the BGP route-selection guide or practice these decisions in the BGP learning experience.

Pass it along

Found this useful? Share it.

Choose a platform or copy the direct link.

LinkedInXFacebook

Continue reading

Reader signal

Was this useful?

Your feedback helps shape the next field note and lab.

… views

Views count when this page opens. You can change or remove your vote during this tab session.