BGP Outbound Traffic Engineering: Where Your Traffic Leaves

Cover image: BGP outbound traffic engineering with LOCAL_PREF, weight, partial routing tables and customer-route communities on a dual-homed edge

You buy a second transit link, configure two eBGP sessions, and a week later the graphs show most of the traffic on the old ISP and the new one almost idle. Nothing is broken. BGP picked one path per prefix, and for most prefixes the decision came down to which session came up first. BGP outbound traffic engineering is the part of routing policy that decides where your traffic leaves your network, and it is the one part of Internet routing that is 100% your decision: you control it with import policy on your own routers, mainly LOCAL_PREF, weight and the choice of which routes you accept at all. This part of the series turns that into designs you can deploy: primary/backup, load sharing by destination, cost- and latency-based exits, default versus partial versus full tables. We test five import policies on a real GoBGP router with two upstreams, and we check the assumptions against a real 1.07-million-prefix table from RIPE RIS.

TL;DR
  • Outbound is yours: every router picks its exit from the routes it accepted. LOCAL_PREF (AS-wide, carried in iBGP), weight (one Cisco/FRR router) and import filtering are the tools; prepending and MED you send only affect inbound.[1][7][12]
  • Without policy, tie-breakers decide: comparing the full tables of AS2914 and AS6762 at RIS rrc14, 57.7% of 1,073,287 prefixes had equal AS_PATH lengths.[14]
  • The classic regex lies a little: on NTT's real feed, ^2914_[0-9]+$ matched 119,695 routes, 10.6% of them NTT peer routes, and missed 302,899 customer routes. NTT's community 2914:410 classifies all of them.[13][14]
  • Lab: the regex policy also caught ISP-B's default route and its peers' routes (6 of 9 prefixes moved instead of 3); a community-based policy with the default handled first moved exactly the 3 intended prefixes.[15]
  • Partial tables need the default: when the full-table ISP failed, r1 withdrew 4 prefixes from the AS in 280 ms and their traffic survived only because ISP-B's default route was accepted.[15]
  • Outbound policy without export policy is a leak: our router re-advertised ISP-A's routes to ISP-B until we looked; RFC 8212 makes "no policy, no routes" the default.[4][15]

Why outbound traffic is 100% your decision

A packet leaving your AS follows the forwarding table of each router it passes, and each router builds that table from its own best paths. Nobody outside your AS can change which of your exits a router chooses; they can only change the routes they send you. RFC 4271 builds this into the decision process: for a route learned from an external peer, "the local BGP speaker computes the degree of preference based on preconfigured policy information", and that value "MUST be used as the LOCAL_PREF value in any IBGP readvertisement".[1] The degree of preference comes before AS_PATH length, ORIGIN and MED, so whatever your neighbours put in those attributes, your policy wins if you set it.

RFC 4116, the IETF summary of multihoming practice, says the same in one line: "Outbound traffic can be shared across ISPs using appropriate exit selection policies", while inbound traffic needs "export policies designed to influence the exit selection of remote sites".[2] Philip Smith's long-running multihoming tutorial lists the policy tools exactly that way: local preference for outbound traffic flows; MED and AS-PATH prepend for inbound.[12]

Table of BGP outbound traffic engineering tools: weight, LOCAL_PREF, accepted routing table, IGP metric, received attributes and inbound-only tools
Figure 1. The outbound toolbox. Everything above the AS_PATH step is set by your own routers; what your neighbours send only matters when you leave it alone.

Four tools act on outbound traffic:

  • LOCAL_PREF. Set by import policy on the router that learns the route, "included in all UPDATE messages that a given BGP speaker sends to other internal peers", and never sent to external peers.[1] Because it travels in iBGP, every router in the AS makes the same choice. Junos documents the same scope: always advertised to internal peers and confederation neighbours, never to EBGP peers, and a route received without it is handled as if it had 100.[9]
  • Weight. Cisco checks it first, before LOCAL_PREF, and is explicit about its scope: "WEIGHT is a Cisco-specific parameter. It is local to the router on which it is configured."[7] FRR has set weight too; Junos and GoBGP have none.[10][11] It is the right tool when one router must ignore the AS-wide decision, and the wrong one for an AS with several edge routers.
  • What you accept. A route you filtered cannot be chosen. Default-only, partial and full tables are the coarsest and most powerful outbound tool (section below).
  • The IGP metric to the exit. When LOCAL_PREF and everything above the IGP step tie, each router uses its nearest exit (hot-potato routing). That is outbound TE through IGP design, covered in part 16.

Cisco's own sample-configuration note for two ISPs makes the distinction precisely: "Load balancing is not possible in a multihomed environment with two ISPs. BGP selects only the single best path to a destination among the BGP paths that are learned from different ASs", "but, load sharing is possible", by policy per destination.[8] Outbound TE is that per-destination load sharing.

What happens with no policy at all

Before tuning anything, it helps to know what BGP does on its own. Our lab has one real BGP router, GoBGP 4.11 (r1, AS 65001), and two upstreams played by raw Python BGP speakers: ISP-A (AS 64500) and ISP-B (AS 64510). Both send the same nine destinations, built so that each case appears once: the default route, a customer of each ISP, paths that are shorter via A or via B, and paths of equal length through a common transit AS 64496. A third raw speaker is an iBGP peer of r1 and shows what the rest of the AS is told. ISP-A sends its routes first, ISP-B 3 seconds later. All ASNs and prefixes are documentation and benchmarking values.[15]

r1$ gobgp global rib -a ipv4
   Network              Next Hop             AS_PATH                 Age        Attrs
*> 0.0.0.0/0            127.0.2.192          64500                   00:00:07   [{Origin: i}]
*  0.0.0.0/0            127.0.2.193          64510                   00:00:04   [{Origin: i}]
*> 64.0.0.0/24          127.0.2.192          64500 64496             00:00:07   [{Origin: i}]
*  64.0.0.0/24          127.0.2.193          64510 64496             00:00:03   [{Origin: i}]
*> 192.0.2.0/24         127.0.2.192          64500 64501             00:00:07   [{Origin: i}]
*  192.0.2.0/24         127.0.2.193          64510 64496 64500 64501 00:00:04   [{Origin: i}]
*> 198.18.0.0/24        127.0.2.193          64510 64498             00:00:03   [{Origin: i}]
*  198.18.0.0/24        127.0.2.192          64500 64496 64499 64498 00:00:07   [{Origin: i}]
*> 198.18.1.0/24        127.0.2.192          64500 64499             00:00:07   [{Origin: i}]
*  198.18.1.0/24        127.0.2.193          64510 64496 64499       00:00:03   [{Origin: i}]
*> 198.18.2.0/24        127.0.2.192          64500 64496 64511       00:00:07   [{Origin: i}]
*  198.18.2.0/24        127.0.2.193          64510 64496 64511       00:00:03   [{Origin: i}]
*> 198.18.3.0/24        127.0.2.193          64510 64505             00:00:04   [{Origin: i}]
*  198.18.3.0/24        127.0.2.192          64500 64496 64510 64505 00:00:07   [{Origin: i}]
*> 198.51.100.0/24      127.0.2.193          64510 64505             00:00:04   [{Origin: i}]
*  198.51.100.0/24      127.0.2.192          64500 64496 64510 64505 00:00:07   [{Origin: i}]
*> 203.0.113.0/24       127.0.2.192          64500 64496 64497       00:00:07   [{Origin: i}]
*  203.0.113.0/24       127.0.2.193          64510 64496 64497       00:00:03   [{Origin: i}]

Six prefixes leave via ISP-A, three via ISP-B. The three via ISP-B are the ones where ISP-B's AS_PATH is shorter. Every prefix with equal length, including the default route, went to ISP-A, and not because ISP-A is better: GoBGP keeps the older eBGP path when everything else ties, as Cisco, Junos and FRR do (part 16 tested that rule step by step). If ISP-B's session had come up first, those prefixes would sit on ISP-B. Restart a session at the wrong moment and your traffic split changes.

How big is the tie in a real table?

Nine lab prefixes prove the mechanism, not the scale. To see the scale we took the RIPE RIS collector rrc14 (at PAIX, Palo Alto) table dump of 5 December 2026 00:00 UTC: 20 peers, 1,102,195 IPv4 prefixes from the largest feed. Five peers send a full table. We picked two transit providers, NTT (AS2914, peer 198.32.176.14) and Sparkle (AS6762, peer 198.32.176.70), and compared their AS_PATHs prefix by prefix with our own MRT parser, counting an AS_SET as one, as RFC 4271 does.[14][1]

Bar chart from a real RIPE RIS table: share of IPv4 prefixes with a shorter AS path via NTT AS2914, via Sparkle AS6762, or equal length
Figure 2. The full tables of two transit providers, prefix by prefix. For more than half of the Internet, AS_PATH length does not choose between them.

Of 1,073,287 prefixes present in both tables, 233,745 (21.8%) have a shorter AS_PATH via NTT, 220,001 (20.5%) via Sparkle, and 619,541 (57.7%) have the same length. A customer of both providers with no import policy would let ORIGIN, MED (which is not compared between two different neighbour ASes) and then the age of the path or the router ID choose the exit for almost 58% of all destinations. Two caveats: RIS receives what these networks send to a route collector, which is close to, but not guaranteed to be, what they send to a paying customer; and prefix counts are not traffic, because a small number of content and cloud prefixes carry most bytes. The direction of the finding is robust either way: AS_PATH length is a weak signal for choosing between two good transit providers.

Pattern 1: primary and backup exit

The simplest policy makes one ISP the primary for everything. Part 9 of this series measured this design in detail; here it is the reference point for the others. In phase B, r1 sets LOCAL_PREF 200 on everything from ISP-A:[15]

r1$ gobgp global rib -a ipv4
   Network              Next Hop             AS_PATH                 Age        Attrs
*> 0.0.0.0/0            127.0.2.192          64500                   00:00:06   [{Origin: i} {LocalPref: 200}]
*  0.0.0.0/0            127.0.2.193          64510                   00:00:03   [{Origin: i}]
*> 64.0.0.0/24          127.0.2.192          64500 64496             00:00:06   [{Origin: i} {LocalPref: 200}]
*  64.0.0.0/24          127.0.2.193          64510 64496             00:00:03   [{Origin: i}]
*> 192.0.2.0/24         127.0.2.192          64500 64501             00:00:06   [{Origin: i} {LocalPref: 200}]
*  192.0.2.0/24         127.0.2.193          64510 64496 64500 64501 00:00:03   [{Origin: i}]
*> 198.18.0.0/24        127.0.2.192          64500 64496 64499 64498 00:00:06   [{Origin: i} {LocalPref: 200}]
*  198.18.0.0/24        127.0.2.193          64510 64498             00:00:03   [{Origin: i}]
*> 198.18.1.0/24        127.0.2.192          64500 64499             00:00:06   [{Origin: i} {LocalPref: 200}]
*  198.18.1.0/24        127.0.2.193          64510 64496 64499       00:00:03   [{Origin: i}]
*> 198.18.2.0/24        127.0.2.192          64500 64496 64511       00:00:06   [{Origin: i} {LocalPref: 200}]
*  198.18.2.0/24        127.0.2.193          64510 64496 64511       00:00:03   [{Origin: i}]
*> 198.18.3.0/24        127.0.2.192          64500 64496 64510 64505 00:00:06   [{Origin: i} {LocalPref: 200}]
*  198.18.3.0/24        127.0.2.193          64510 64505             00:00:03   [{Origin: i}]
*> 198.51.100.0/24      127.0.2.192          64500 64496 64510 64505 00:00:06   [{Origin: i} {LocalPref: 200}]
*  198.51.100.0/24      127.0.2.193          64510 64505             00:00:03   [{Origin: i}]
*> 203.0.113.0/24       127.0.2.192          64500 64496 64497       00:00:06   [{Origin: i} {LocalPref: 200}]
*  203.0.113.0/24       127.0.2.193          64510 64496 64497       00:00:03   [{Origin: i}]

All nine prefixes now leave via ISP-A, including the three where ISP-B has the shorter path. The iBGP observer received each route with LOCAL_PREF 200, so every other router in the AS makes the same choice without any local configuration:

5.029 I  rx type=2 len=51 ORIGIN=0 | AS_PATH=64500 | NH=127.0.2.192 | LP=200 | NLRI 0.0.0.0/0 
5.079 I  rx type=2 len=58 ORIGIN=0 | AS_PATH=64500 64501 | NH=127.0.2.192 | LP=200 | NLRI 192.0.2.0/24 
5.130 I  rx type=2 len=66 ORIGIN=0 | AS_PATH=64500 64496 64510 64505 | NH=127.0.2.192 | LP=200 | NLRI 198.51.100.0/24 

Then the ISP-A session drops (we close the TCP connection without a NOTIFICATION). r1 had ISP-B's full table in its Adj-RIB-In all along, so it only had to pick the next path. The first UPDATE to the iBGP observer left 412 ms after the close, now via ISP-B with the default LOCAL_PREF 100:

12.514 I  rx type=2 len=51 ORIGIN=0 | AS_PATH=64510 | NH=127.0.2.193 | LP=100 | NLRI 0.0.0.0/0 
12.514 I  rx type=2 len=62 ORIGIN=0 | AS_PATH=64510 64505 | NH=127.0.2.193 | LP=100 | NLRI 198.51.100.0/24,198.18.3.0/24 
12.514 I  rx type=2 len=62 ORIGIN=0 | AS_PATH=64510 64496 64499 | NH=127.0.2.193 | LP=100 | NLRI 198.18.1.0/24 
r1$ gobgp global rib -a ipv4
   Network              Next Hop             AS_PATH                 Age        Attrs
*> 0.0.0.0/0            127.0.2.193          64510                   00:00:07   [{Origin: i}]
*> 64.0.0.0/24          127.0.2.193          64510 64496             00:00:07   [{Origin: i}]
*> 192.0.2.0/24         127.0.2.193          64510 64496 64500 64501 00:00:07   [{Origin: i}]
*> 198.18.0.0/24        127.0.2.193          64510 64498             00:00:07   [{Origin: i}]
*> 198.18.1.0/24        127.0.2.193          64510 64496 64499       00:00:07   [{Origin: i}]
*> 198.18.2.0/24        127.0.2.193          64510 64496 64511       00:00:07   [{Origin: i}]
*> 198.18.3.0/24        127.0.2.193          64510 64505             00:00:07   [{Origin: i}]
*> 198.51.100.0/24      127.0.2.193          64510 64505             00:00:07   [{Origin: i}]
*> 203.0.113.0/24       127.0.2.193          64510 64496 64497       00:00:07   [{Origin: i}]

When ISP-A came back and re-sent its routes, all nine moved back to ISP-A with LOCAL_PREF 200. Two practical notes. First, the 412 ms is measured from the moment r1 learned of the failure; on a loopback lab that is instant. On a real link a silent failure is detected by the hold timer (90 s in this lab), a shorter configured hold time, or BFD (RFC 5880), and detection usually dominates the outage.[5] Second, "backup" only describes outbound traffic. Whether return traffic also avoids the backup link depends on what you advertise and on the ISPs' policies, which is the subject of part 18.

The cost-based variant is the same mechanism with a business reason: set LOCAL_PREF per ISP from the price per Mbit/s, so the cheaper transit is primary. A finer version, useful when you have a committed rate on one link, raises LOCAL_PREF for a prefix list of heavy destinations on the link with spare commit. Junos documents the motive directly: one path "might be less expensive to use, might have higher bandwidth, or might be more stable".[9]

Pattern 2: load sharing by destination

Primary/backup leaves one link idle. The usual next step is to send each ISP's own customers via that ISP (the shortest, most direct path, and the traffic the ISP carries on its own network) and everything else via the other. Cisco's 2005 sample configuration does it with an AS-path access list, ip as-path access-list 1 permit ^400$, and set local-preference 150 for matching routes.[8] Philip Smith's tutorial uses the extended form that also takes the ISP's direct customers: ^(130_)+$ and ^(130_)+_[0-9]+$ get LOCAL_PREF 120, everything else 80.[12]

Lab: the regex policy

Phase C implements that idea literally: ISP-A gets LOCAL_PREF 150 for everything, and ISP-B gets 200 for routes matching ^64510$ or ^64510_[0-9]+$ plus a one-prefix "latency" list (198.18.2.0/24), and the default 100 otherwise. GoBGP's AS-path sets use the Quagga/Cisco regex syntax, where _ matches a separator or the start or end of the path:[11]

[[defined-sets.bgp-defined-sets.as-path-sets]]
  as-path-set-name = "isp-b-customers"
  as-path-list = ["^64510$", "^64510_[0-9]+$"]

We intended to move three prefixes to ISP-B: its two customer routes (AS 64505) and the latency target. The result moved six:

r1$ gobgp global rib -a ipv4
   Network              Next Hop             AS_PATH                 Age        Attrs
*> 0.0.0.0/0            127.0.2.193          64510                   00:00:03   [{Origin: i} {LocalPref: 200}]
*  0.0.0.0/0            127.0.2.192          64500                   00:00:07   [{Origin: i} {LocalPref: 150}]
*> 64.0.0.0/24          127.0.2.193          64510 64496             00:00:03   [{Origin: i} {LocalPref: 200}]
*  64.0.0.0/24          127.0.2.192          64500 64496             00:00:06   [{Origin: i} {LocalPref: 150}]
*> 192.0.2.0/24         127.0.2.192          64500 64501             00:00:07   [{Origin: i} {LocalPref: 150}]
*  192.0.2.0/24         127.0.2.193          64510 64496 64500 64501 00:00:03   [{Origin: i}]
*> 198.18.0.0/24        127.0.2.193          64510 64498             00:00:03   [{Origin: i} {LocalPref: 200}]
*  198.18.0.0/24        127.0.2.192          64500 64496 64499 64498 00:00:06   [{Origin: i} {LocalPref: 150}]
*> 198.18.1.0/24        127.0.2.192          64500 64499             00:00:06   [{Origin: i} {LocalPref: 150}]
*  198.18.1.0/24        127.0.2.193          64510 64496 64499       00:00:03   [{Origin: i}]
*> 198.18.2.0/24        127.0.2.193          64510 64496 64511       00:00:03   [{Origin: i} {LocalPref: 200}]
*  198.18.2.0/24        127.0.2.192          64500 64496 64511       00:00:06   [{Origin: i} {LocalPref: 150}]
*> 198.18.3.0/24        127.0.2.193          64510 64505             00:00:03   [{Origin: i} {LocalPref: 200}]
*  198.18.3.0/24        127.0.2.192          64500 64496 64510 64505 00:00:06   [{Origin: i} {LocalPref: 150}]
*> 198.51.100.0/24      127.0.2.193          64510 64505             00:00:03   [{Origin: i} {LocalPref: 200}]
*  198.51.100.0/24      127.0.2.192          64500 64496 64510 64505 00:00:07   [{Origin: i} {LocalPref: 150}]
*> 203.0.113.0/24       127.0.2.192          64500 64496 64497       00:00:06   [{Origin: i} {LocalPref: 150}]
*  203.0.113.0/24       127.0.2.193          64510 64496 64497       00:00:03   [{Origin: i}]

Three surprises, all correct regex behaviour:

  • The default route matched ^64510$. ISP-B originates the default, so its AS_PATH is just 64510. Every destination not covered by a more specific route now leaves via ISP-B, the opposite of "ISP-A for the rest".
  • 64510 64496 matched too. AS 64496 is the common transit, not ISP-B's customer. "One AS behind ISP-B" means customer or peer of ISP-B; the regex cannot tell them apart.
  • 64510 64498 matched. Whether AS 64498 buys transit from ISP-B or peers with it, the path looks identical.

The iBGP observer received exactly this mix, so the whole AS followed it:

r1$ gobgp neighbor 127.0.2.194 adj-out -a ipv4
   ID  Network              Next Hop             AS_PATH              AttrsFiltered
   2   0.0.0.0/0            127.0.2.193          64510                [{Origin: i} {LocalPref: 200}]not filtered
   2   64.0.0.0/24          127.0.2.193          64510 64496          [{Origin: i} {LocalPref: 200}]not filtered
   1   192.0.2.0/24         127.0.2.192          64500 64501          [{Origin: i} {LocalPref: 150}]not filtered
   2   198.18.0.0/24        127.0.2.193          64510 64498          [{Origin: i} {LocalPref: 200}]not filtered
   1   198.18.1.0/24        127.0.2.192          64500 64499          [{Origin: i} {LocalPref: 150}]not filtered
   2   198.18.2.0/24        127.0.2.193          64510 64496 64511    [{Origin: i} {LocalPref: 200}]not filtered
   2   198.18.3.0/24        127.0.2.193          64510 64505          [{Origin: i} {LocalPref: 200}]not filtered
   2   198.51.100.0/24      127.0.2.193          64510 64505          [{Origin: i} {LocalPref: 200}]not filtered
   1   203.0.113.0/24       127.0.2.192          64500 64496 64497    [{Origin: i} {LocalPref: 150}]not filtered

Real data: regex versus the provider's own tag

Is that a lab artefact? Large transit networks tag every route with where they learned it. NTT documents two communities on routes it sends to customers: 2914:410 "NTT and customer routes" and 2914:420 "Peer routes".[13] The NTT feed at RIS rrc14 carries one of the two on every one of its 1,074,095 IPv4 routes, so we can measure the regex against NTT's own classification. Prepends are collapsed first (a literal ^2914_[0-9]+$ would match even fewer routes, because 2914 16509 16509 fails it).[14]

Table comparing an AS-path regular expression with NTT 2914:410 and 2914:420 communities on a real BGP feed: the regex includes peer routes and misses deeper customer routes
Figure 3. NTT's real feed classified twice: by AS_PATH shape and by NTT's own customer/peer communities.
  • Own routes (^2914$): 1,615, all tagged 410.
  • One AS behind NTT: 119,695 routes. 106,963 are customer routes, but 12,732 (10.6%) are peer routes. Example: 12.0.0.0/8 with AS_PATH 2914 7018, tagged 2914:1008, 2914:2000, 2914:3000, 2914:420. AS 7018 is a large network in its own right, and NTT reaches it over peering.
  • Deeper customer routes: 302,899 routes are in NTT's customer cone but two or more ASes deep, for example 36.128.0.0/10 via 2914 2914 58453 58453 58453 9808. The regex never sees them.

So the textbook regex selects roughly a quarter of NTT's real customer cone (108,578 of 411,477 customer routes, the cone being 38.3% of the table) and adds 12,732 routes that are not customer routes at all. If your goal is "use ISP-B for ISP-B's customers", match ISP-B's customer community.

Lab: the fixed policy

Phase E repeats phase C with two changes. ISP-B now tags its routes the way NTT does (64510:410 on its customer routes, 64510:420 on the others; our raw speaker sends the community on the wire):[15]

8.529 B  tx type=2 len=66 ORIGIN=0 | AS_PATH=64510 64496 64500 64501 | NH=127.0.2.193 | COMM[fl=0xc0 len=4]=64510:420 {c00804fbfe01a4} | NLRI 192.0.2.0/24 customer of ISP-A
8.579 B  tx type=2 len=58 ORIGIN=0 | AS_PATH=64510 64505 | NH=127.0.2.193 | COMM[fl=0xc0 len=4]=64510:410 {c00804fbfe019a} | NLRI 198.51.100.0/24 customer of ISP-B

And r1's policy handles the default route first, leaving it at LOCAL_PREF 100, then raises LOCAL_PREF only for the customer community and the latency list:

[[policy-definitions]]
  name = "isp-b-in"
  [[policy-definitions.statements]]
    name = "default-unchanged"
    [policy-definitions.statements.conditions.match-prefix-set]
      prefix-set = "default-route"
      match-set-options = "any"
    [policy-definitions.statements.actions]
      route-disposition = "accept-route"
  [[policy-definitions.statements]]
    name = "b-customers"
    [policy-definitions.statements.conditions.bgp-conditions.match-community-set]
      community-set = "isp-b-customer-routes"
      match-set-options = "any"
    [policy-definitions.statements.actions]
      route-disposition = "accept-route"
    [policy-definitions.statements.actions.bgp-actions]
      set-local-pref = 200
  [[policy-definitions.statements]]
    name = "latency"
    [policy-definitions.statements.conditions.match-prefix-set]
      prefix-set = "latency-via-b"
      match-set-options = "any"
    [policy-definitions.statements.actions]
      route-disposition = "accept-route"
    [policy-definitions.statements.actions.bgp-actions]
      set-local-pref = 200
  [[policy-definitions.statements]]
    name = "rest"
    [policy-definitions.statements.actions]
      route-disposition = "accept-route"

Exactly the three intended prefixes leave via ISP-B; the default route and the other six use ISP-A at LOCAL_PREF 150:

r1$ gobgp global rib -a ipv4
   Network              Next Hop             AS_PATH                 Age        Attrs
*> 0.0.0.0/0            127.0.2.192          64500                   00:00:07   [{Origin: i} {LocalPref: 150}]
*  0.0.0.0/0            127.0.2.193          64510                   00:00:04   [{Origin: i}]
*> 64.0.0.0/24          127.0.2.192          64500 64496             00:00:07   [{Origin: i} {LocalPref: 150}]
*  64.0.0.0/24          127.0.2.193          64510 64496             00:00:03   [{Origin: i} {Communities: 64510:420}]
*> 192.0.2.0/24         127.0.2.192          64500 64501             00:00:07   [{Origin: i} {LocalPref: 150}]
*  192.0.2.0/24         127.0.2.193          64510 64496 64500 64501 00:00:04   [{Origin: i} {Communities: 64510:420}]
*> 198.18.0.0/24        127.0.2.192          64500 64496 64499 64498 00:00:07   [{Origin: i} {LocalPref: 150}]
*  198.18.0.0/24        127.0.2.193          64510 64498             00:00:04   [{Origin: i} {Communities: 64510:420}]
*> 198.18.1.0/24        127.0.2.192          64500 64499             00:00:07   [{Origin: i} {LocalPref: 150}]
*  198.18.1.0/24        127.0.2.193          64510 64496 64499       00:00:04   [{Origin: i} {Communities: 64510:420}]
*> 198.18.2.0/24        127.0.2.193          64510 64496 64511       00:00:03   [{Origin: i} {LocalPref: 200} {Communities: 64510:420}]
*  198.18.2.0/24        127.0.2.192          64500 64496 64511       00:00:07   [{Origin: i} {LocalPref: 150}]
*> 198.18.3.0/24        127.0.2.193          64510 64505             00:00:04   [{Origin: i} {LocalPref: 200} {Communities: 64510:410}]
*  198.18.3.0/24        127.0.2.192          64500 64496 64510 64505 00:00:07   [{Origin: i} {LocalPref: 150}]
*> 198.51.100.0/24      127.0.2.193          64510 64505             00:00:04   [{Origin: i} {LocalPref: 200} {Communities: 64510:410}]
*  198.51.100.0/24      127.0.2.192          64500 64496 64510 64505 00:00:07   [{Origin: i} {LocalPref: 150}]
*> 203.0.113.0/24       127.0.2.192          64500 64496 64497       00:00:07   [{Origin: i} {LocalPref: 150}]
*  203.0.113.0/24       127.0.2.193          64510 64496 64497       00:00:04   [{Origin: i} {Communities: 64510:420}]

Statement order matters as much as the match. In GoBGP a route-disposition means "stop following policy/statement evaluation and accept/reject the route"; a Junos term with then accept is terminating in the same way, and a Cisco route-map stops at the first matching permit sequence. A broad match placed before the default-route clause therefore decides for the default too.[11][9]

BGP outbound traffic engineering lab: one GoBGP edge router with two ISPs and the best exit per prefix under five import policies
Figure 4. The best exit for each of the nine lab prefixes under the five policies. Phase C shows how an innocent regex moves the default route; phase E is the corrected design.

Pattern 3: latency-based and application exits

Sometimes a handful of destinations matter more than the rest: a SaaS provider, a payment gateway, a partner network. LOCAL_PREF on a short prefix list does it, as the latency-via-b set did for 198.18.2.0/24 in phases C and E. The list should come from your own measurements (RTT and loss per exit, for example from probes sourced from each edge router), not from AS_PATH length; RFC 4116 notes that import policies can make "exit selection to avoid paths known to be problematic", and in the same breath that many traffic engineering goals "can only be loosely approximated".[2] Keep such lists short and owned by someone, because destinations move between providers and the measurement that justified an entry ages.

Pattern 4: default, partial or full table

The coarsest outbound tool is the set of routes you accept from each ISP. The three classic choices:

Bar chart of routing table sizes for default-only, partial and full BGP feeds and a table of what outbound control each option gives
Figure 5. Route counts from NTT's real feed: a default route, a 'one AS behind' partial table, the customer cone marked by 2914:410, and the full table.
  • Default route only. One route per ISP. Redundancy is easy (primary default with LOCAL_PREF, backup default without), per-destination steering is impossible. Smith's tutorial lists "You need the full routing table to multihome" as myth number one.[12]
  • Default plus partial routes. Each ISP's own and customer routes plus a default. On NTT's feed that is 411,477 routes (38.3% of the table) if you filter by its customer community, or 121,310 with the one-hop regex. Destinations in an ISP's cone go direct; the rest follows the defaults.
  • Full tables from all. Per-prefix choice for everything, at the cost of RIB and FIB memory and CPU per ISP. RFC 7454 recommends a maximum-prefix limit on full-table upstreams "higher than the number of routes in the Internet" to protect the router.[3]

Lab: failover with a partial table

Phase D accepts the full table from ISP-A and only ^64510(_[0-9]+)?$ routes plus the default from ISP-B, rejecting the rest. Steady state looks fine:

r1$ gobgp global rib -a ipv4
   Network              Next Hop             AS_PATH                 Age        Attrs
*> 0.0.0.0/0            127.0.2.193          64510                   00:00:04   [{Origin: i} {LocalPref: 200}]
*  0.0.0.0/0            127.0.2.192          64500                   00:00:07   [{Origin: i}]
*> 64.0.0.0/24          127.0.2.193          64510 64496             00:00:04   [{Origin: i} {LocalPref: 200}]
*  64.0.0.0/24          127.0.2.192          64500 64496             00:00:07   [{Origin: i}]
*> 192.0.2.0/24         127.0.2.192          64500 64501             00:00:07   [{Origin: i}]
*> 198.18.0.0/24        127.0.2.193          64510 64498             00:00:04   [{Origin: i} {LocalPref: 200}]
*  198.18.0.0/24        127.0.2.192          64500 64496 64499 64498 00:00:07   [{Origin: i}]
*> 198.18.1.0/24        127.0.2.192          64500 64499             00:00:07   [{Origin: i}]
*> 198.18.2.0/24        127.0.2.192          64500 64496 64511       00:00:07   [{Origin: i}]
*> 198.18.3.0/24        127.0.2.193          64510 64505             00:00:04   [{Origin: i} {LocalPref: 200}]
*  198.18.3.0/24        127.0.2.192          64500 64496 64510 64505 00:00:07   [{Origin: i}]
*> 198.51.100.0/24      127.0.2.193          64510 64505             00:00:04   [{Origin: i} {LocalPref: 200}]
*  198.51.100.0/24      127.0.2.192          64500 64496 64510 64505 00:00:07   [{Origin: i}]
*> 203.0.113.0/24       127.0.2.192          64500 64496 64497       00:00:07   [{Origin: i}]

Then ISP-A fails. This time r1 had no alternative path for four of the prefixes, because it had rejected them from ISP-B. It withdrew them from the rest of the AS 280 ms after the session closed:

12.387 I  rx type=2 len=27 WITHDRAW 203.0.113.0/24 
12.387 I  rx type=2 len=27 WITHDRAW 198.18.1.0/24 
12.387 I  rx type=2 len=31 WITHDRAW 198.18.2.0/24,192.0.2.0/24 
r1$ gobgp global rib -a ipv4
   Network              Next Hop             AS_PATH              Age        Attrs
*> 0.0.0.0/0            127.0.2.193          64510                00:00:07   [{Origin: i} {LocalPref: 200}]
*> 64.0.0.0/24          127.0.2.193          64510 64496          00:00:07   [{Origin: i} {LocalPref: 200}]
*> 198.18.0.0/24        127.0.2.193          64510 64498          00:00:07   [{Origin: i} {LocalPref: 200}]
*> 198.18.3.0/24        127.0.2.193          64510 64505          00:00:07   [{Origin: i} {LocalPref: 200}]
*> 198.51.100.0/24      127.0.2.193          64510 64505          00:00:07   [{Origin: i} {LocalPref: 200}]

Only five routes are left, and traffic to 192.0.2.0/24, 198.18.1.0/24, 198.18.2.0/24 and 203.0.113.0/24 now follows the default route via ISP-B. That is the design working as intended, and it shows the one rule of partial tables: the default route from the partial-table ISP must be accepted and must stay accepted. A filter that drops it (or a prefix list that forgets 0.0.0.0/0) turns an ISP failure into an outage for most of the Internet.

Timeline of BGP outbound failover: with a full backup table routes switch to ISP-B in 0.4 s, with a partial table four prefixes are withdrawn and fall back to the default route
Figure 6. The same ISP-A failure with a full backup table (phase B) and a partial one (phase D), as seen by the rest of the AS.

One GoBGP detail to keep in mind when you verify a partial table: the neighbour summary still showed ISP-B as 9 9 (received and accepted), and the Adj-RIB-In listed all nine routes, although the import policy had rejected four of them. Check the RIB itself, not the summary counter:

r1$ gobgp neighbor
Peer           AS  Up/Down State       |#Received  Accepted
127.0.2.192 64500 00:00:03 Active      |        0         0
127.0.2.193 64510 00:00:12 Establ      |        9         9
127.0.2.194 65001 00:00:12 Establ      |        0         0

The other half: export policy

All the patterns above are import policy. Each one assumes you also have an export policy that advertises only your own prefixes to each ISP. Our lab router had none, and it did what RFC 4271 allows: it advertised its best paths to every eBGP neighbour. In phase A, ISP-B received 8 UPDATEs from r1, among them ISP-A's routes with r1's AS in front:

5.028 B  rx type=2 len=48 ORIGIN=0 | AS_PATH=65001 64500 | NH=127.0.2.191 | NLRI 0.0.0.0/0 
5.077 B  rx type=2 len=55 ORIGIN=0 | AS_PATH=65001 64500 64501 | NH=127.0.2.191 | NLRI 192.0.2.0/24 
5.228 B  rx type=2 len=59 ORIGIN=0 | AS_PATH=65001 64500 64496 64497 | NH=127.0.2.191 | NLRI 203.0.113.0/24 

In the real Internet that is a route leak: your AS offers transit between your two providers. RFC 8212 changed the default for exactly this reason: "Routes SHALL NOT be added to an Adj-RIB-Out associated with an EBGP peer if no explicit Export Policy has been applied", and the same for import.[4] FRR enforces it by default (bgp ebgp-requires-policy); GoBGP 4.11 in our lab did not, so check the default of your own platform rather than assuming it.[10][15] Whatever outbound policy you design, pair every ISP session with an export filter for your own prefixes and a maximum-prefix limit inbound.[3]

Choosing a pattern

Table of five BGP outbound traffic engineering patterns: primary backup, cost based, by destination, latency based and default plus partial routes
Figure 7. Five outbound patterns, the import policy behind each and the catch to watch.

In practice designs combine: a full or partial table from both ISPs, the cheaper one preferred with LOCAL_PREF 150, the other ISP's customer routes at 200 by community, a short latency list at 200, and every default at 100 as a last resort. Use LOCAL_PREF bands with gaps (for example 50 backup, 100 default, 150 preferred ISP, 200 targeted routes) so that a new rule fits between existing ones, and write the bands down; part 9 showed how transit networks publish theirs as customer communities.

Two design points are easy to miss with more than one edge router. First, set LOCAL_PREF on the router that learns the route from the ISP, on import. iBGP carries the value to everyone else; a route reflector should pass it unchanged. Second, if both exits have the same LOCAL_PREF, every router chooses its nearest exit by IGP metric, which is often what you want for latency and the reason two routers in one AS can legitimately use different ISPs for the same destination.

Configuration examples

The policy from phase E (ISP-A preferred at 150, ISP-B customer routes and a latency list at 200, ISP-B's default left at 100) in three vendor syntaxes. These are configuration examples written from vendor documentation, not runs; only the GoBGP version above was run in our lab. Addresses are documentation values.[7][8][9][10]

! Cisco IOS / IOS XE - two ISPs on one or two edge routers (configuration example)
ip bgp-community new-format
ip community-list standard ISPB-CUSTOMER permit 64510:410
ip prefix-list DEFAULT seq 5 permit 0.0.0.0/0
ip prefix-list LOW-LATENCY seq 5 permit 198.18.2.0/24
!
route-map ISP-A-IN permit 10
 set local-preference 150
!
route-map ISP-B-IN permit 10
 match ip address prefix-list DEFAULT
 ! default from ISP-B stays at 100: backup only
route-map ISP-B-IN permit 20
 match community ISPB-CUSTOMER
 set local-preference 200
route-map ISP-B-IN permit 30
 match ip address prefix-list LOW-LATENCY
 set local-preference 200
route-map ISP-B-IN permit 40
!
router bgp 65001
 neighbor 192.0.2.1 remote-as 64500
 neighbor 192.0.2.1 route-map ISP-A-IN in
 neighbor 192.0.2.1 route-map MY-PREFIXES-ONLY out
 neighbor 192.0.2.1 maximum-prefix 1500000 90 warning-only
 neighbor 198.51.100.1 remote-as 64510
 neighbor 198.51.100.1 route-map ISP-B-IN in
 neighbor 198.51.100.1 route-map MY-PREFIXES-ONLY out
!
! one-router variant with weight instead of LOCAL_PREF (local to this router only):
! route-map ISP-A-IN permit 10
!  set weight 200
# Junos (configuration example)
set policy-options community ISPB-CUSTOMER members 64510:410
set policy-options policy-statement ISP-A-IN term all then local-preference 150
set policy-options policy-statement ISP-B-IN term default from route-filter 0.0.0.0/0 exact
set policy-options policy-statement ISP-B-IN term default then accept
set policy-options policy-statement ISP-B-IN term cust from community ISPB-CUSTOMER
set policy-options policy-statement ISP-B-IN term cust then local-preference 200
set policy-options policy-statement ISP-B-IN term cust then accept
set protocols bgp group isp-a type external import ISP-A-IN
set protocols bgp group isp-b type external import ISP-B-IN
! FRR (configuration example; FRR enforces RFC 8212 by default: no policy, no routes)
bgp community-list standard ISPB-CUSTOMER permit 64510:410
ip prefix-list DEFAULT seq 5 permit 0.0.0.0/0
route-map ISP-B-IN permit 10
 match ip address prefix-list DEFAULT
route-map ISP-B-IN permit 20
 match community ISPB-CUSTOMER
 set local-preference 200
route-map ISP-B-IN permit 30
route-map ISP-A-IN permit 10
 set local-preference 150
router bgp 65001
 neighbor 192.0.2.1 remote-as 64500
 neighbor 198.51.100.1 remote-as 64510
 address-family ipv4 unicast
  neighbor 192.0.2.1 route-map ISP-A-IN in
  neighbor 198.51.100.1 route-map ISP-B-IN in

Junos note: the group-level local-preference statement sets the value on routes advertised to that group, not on routes received; for outbound TE use an import policy as above.[9] Junos also has local-preference add/subtract actions, and FRR set local-preference +N/-N, useful for adjusting a community-derived value per site.[9][10]

Verification and monitoring

An outbound policy is only done when you can show where traffic goes. A short checklist:

  • Per prefix: show bgp ipv4 unicast <prefix> (IOS XR, FRR), show ip bgp <prefix> (IOS), show route <prefix> detail (Junos): the best path, its LOCAL_PREF and the policy that set it.
  • Per exit: count best paths per next hop, for example show ip bgp regexp ^64510_ or show ip bgp community 64510:410 on Cisco, show route receive-protocol bgp <neighbor> active-path on Junos. Compare the count before and after a change; our lab moved from 6/3 to 9/0 to 3/6 to 6/3 between phases.
  • What iBGP peers see: the advertised routes towards an internal peer or route reflector must carry the LOCAL_PREF you expect (show ip bgp neighbors <rr> advertised-routes). Our observer was the proof for every phase.
  • Traffic, not prefixes: interface counters per ISP and flow data (NetFlow/IPFIX, sFlow) by destination AS. The RIS numbers above are prefix counts; a few prefixes can carry most of the bytes.
  • Policy drift: after an ISP changes its community scheme or a provider merger, re-run the per-exit counts. A community that no longer matches silently returns those routes to the default band.
  • Failure test: shut one session in a maintenance window and confirm that every destination still has a path, especially with partial tables.

Common mistakes

SymptomLikely causeFix
Almost all traffic on one ISP after both sessions are upNo policy; equal AS_PATH lengths resolved by path age or router IDSet LOCAL_PREF per ISP or per destination group; do not rely on session order
Changing weight on one router has no effect elsewhereWeight is local to one routerUse LOCAL_PREF set on import
Everything without a specific route uses the "wrong" ISPThe default route matched a broad statement (^AS$)Handle 0.0.0.0/0 in its own first statement
"Customer routes" policy moves too much trafficAS-path regex matches the ISP's peersMatch the ISP's customer community instead
Partial table: outage when the other ISP failsDefault route filtered from the partial-table ISPAccept and keep the default; test the failure
Junos local-preference on the eBGP group does nothingThat statement sets the value on advertised routesUse then local-preference in an import policy
ISP complains about your announcementsNo export policy: you leak one ISP's routes to the otherExport only your prefixes; RFC 8212 behaviour

FAQ

What is BGP outbound traffic engineering?

It is choosing which of your exits (ISPs, peers, border routers) traffic uses when it leaves your autonomous system. Because every BGP router picks its own best path from the routes it accepted, outbound traffic is fully under your control: you change it with inbound (import) policy on your own eBGP sessions, mainly LOCAL_PREF, Cisco weight and filtering of what you accept.

Which BGP attribute controls outbound traffic?

LOCAL_PREF. It is set by import policy on the router that learns the route from an ISP, carried to every iBGP peer and compared second (after Cisco weight) in best-path selection, so the whole AS agrees on the exit. Weight does the same on one router only and is never advertised.

Weight or LOCAL_PREF for a dual-ISP setup?

With one edge router both work. With two or more edge routers use LOCAL_PREF, because weight stays inside the router where it is set and the other routers would still choose by AS_PATH length and tie-breakers. Weight is Cisco- and FRR-specific; Junos has no weight.

Do I need the full Internet table to multihome?

No. A default route from each ISP is enough for redundancy. Full tables give per-prefix choice, partial tables (each ISP's own and customer routes plus a default) give most of the useful choice with a fraction of the routes. In the NTT feed we measured, the customer cone was 411,477 of 1,074,095 IPv4 routes. Keep the default route when you accept a partial table, or the rest of the Internet becomes unreachable when the other ISP fails.

How do I send traffic to a provider's customers via that provider?

Match the provider's customer routes and give them a higher LOCAL_PREF. The reliable match is the provider's own community (for example NTT tags customer routes 2914:410 and peer routes 2914:420). The common AS-path regex ^AS_[0-9]+$ also matches the provider's peers and misses customers deeper in the cone; on the real NTT feed 10.6% of its matches were peer routes.

Why does most of my traffic still go out of one ISP?

Because without policy the tie-breakers after AS_PATH decide. Comparing the full tables of AS2914 and AS6762 at RIPE RIS, 57.7% of prefixes had equal AS_PATH lengths, and those go to the older path or the lower router ID, usually the ISP whose session came up first. Prefix counts are also not traffic: a few prefixes (CDNs, clouds) carry most bytes, so measure with flow data.

Can outbound policy affect inbound traffic?

Not directly. LOCAL_PREF is never sent to eBGP neighbours. Inbound traffic depends on what you advertise and on your neighbours' policy (prepending, MED, more-specifics, provider communities), which is the next part of the series. Asymmetric routing (out via one ISP, back via the other) is normal and fine for stateless forwarding, but matters for stateful firewalls.

How we tested

All GoBGP output is real GoBGP 4.11 output from router r1 on 127.0.2.191 (port 10179), run on 5 December 2026 at about 05:00 CET in five phases (A no policy, B ISP-A primary, C regex, D partial table from ISP-B, E community-based fix). ISP-A, ISP-B and the iBGP observer are our own Python BGP speakers that send hand-built UPDATEs and record every byte r1 sends back; failure means closing the TCP session. The RIS numbers come from the rrc14 bview of 5 December 2026 00:00 UTC, parsed with our own MRT TABLE_DUMP_V2 parser; NTT's community meanings are from NTT's published routing policy. Vendor configurations are documentation examples.

Part 17 of 26 — BGP Deep Dive
Series hub: BGP in 26 Parts: From EGP to EVPN
Previous: BGP Best Path Selection: Every Tie-Breaker in Order
Next: BGP Inbound Traffic Engineering: Prepending, MED, More-Specifics and Provider Communities (coming soon)

References

[1] Y. Rekhter, T. Li, S. Hares (Eds.), RFC 4271: A Border Gateway Protocol 4 (BGP-4), January 2006: s.5.1.5, 9.1.1, 9.1.2.2.
[2] J. Abley, K. Lindqvist, E. Davies, B. Black, V. Gill, RFC 4116: IPv4 Multihoming Practices and Limitations, July 2005: s.4.2, 4.3.
[3] J. Durand, I. Pepelnjak, G. Doering, RFC 7454: BGP Operations and Security, February 2015: s.8 Maximum Prefixes.
[4] J. Mauch, J. Snijders, G. Hankins, RFC 8212: Default External BGP (EBGP) Route Propagation Behavior without Policies, July 2017.
[5] D. Katz, D. Ward, RFC 5880: Bidirectional Forwarding Detection (BFD), June 2010.
[6] E. Chen, T. Bates, RFC 1998: An Application of the BGP Community Attribute in Multi-home Routing, August 1996.
[7] Cisco, Select BGP Best-path Algorithm (Document 13753), read 5 December 2026.
[8] Cisco, Load Sharing with BGP in Single and Multihomed Environments: Sample Configurations (Document 13762, updated 2005), PDF copy, read 5 December 2026.
[9] Juniper Networks / HPE, Junos local-preference statement, Local Preference for BGP Routes and Actions in Routing Policy Terms, read 5 December 2026.
[10] FRRouting, Route Maps (set local-preference, set weight) and BGP (bgp ebgp-requires-policy), read 5 December 2026.
[11] GoBGP, Policy configuration (as-path-sets, prefix-sets, set-local-pref), read 5 December 2026.
[12] P. Smith, BGP Multihoming Techniques, NANOG 41, October 2007.
[13] NTT Global IP Network, Routing policies: BGP communities (2914:410, 2914:420), read 5 December 2026.
[14] RIPE NCC, RIS rrc14 bview 2026-12-05 00:00 UTC, peers 198.32.176.14 (AS2914) and 198.32.176.70 (AS6762), parsed with our own MRT parser.
[15] Network freak lab: GoBGP 4.11 router r1 (127.0.2.191) with raw Python BGP speakers ISP-A, ISP-B and an iBGP observer, phases A-E, 5 December 2026. Configs, logs and every UPDATE are kept with the article sources.
Figures 1-7: Network freak, drawn from the sources above and our lab.

Try it: BGP Route Lookup: origin AS, AS paths and RPKI check - look up any prefix and see which upstreams carry it, free and in your browser.

Comments

Popular posts from this blog

BGP Neighbor States

Reason legend in show ip ospf statistics

Cisco SPAN Port Mirroring for Troubleshooting