
BGP traffic engineering on AWS: AS-path, communities, and the edge cases that bite: Resilient Cloud Networking on AWS — Patterns from the Field, Article 7
BGP traffic engineering on AWS Direct Connect: how AWS evaluates local preference, AS-path, MED — and the asymmetric routing edge cases that bite.
A multinational retailer running active-active across two AWS Direct Connect (DX) locations had spent a quarter chasing intermittent application failures on the return path. Both DX paths were up, every Border Gateway Protocol (BGP) session was active, and the team had even sprinkled in AS-path prepending on what they considered the secondary path to "discourage" AWS from preferring it. The application engineers were convinced AWS was the culprit. The network engineers were convinced everything was symmetric. They were both partly right and entirely stuck.
What was actually happening is that the prepended AS-path attribute was being ignored by the AWS side, because the same prefix was being advertised on both paths with the same default local preference. AWS evaluates the local preference community before AS-path length, so the prepend never got its turn. Equal-cost multi-path (ECMP) kicked in and return traffic for a given session landed on whichever AWS device shortest-prefixed it first. The on-premises stateful firewall, which only saw the outbound half of the session through one metro, dropped the inbound half that came back through the other. The drops were concentrated on long-lived flows, which is why the team only saw them on certain backend integrations and why the diagrams kept showing everything as "fine."
That class of edge case is what BGP traffic engineering on DX is really about. It is not just the syntax of attributes. It is understanding the order in which the AWS side evaluates them, the asymmetries the system tolerates by design, and the on-premises behaviors that turn a perfectly conformant BGP setup into an application-layer incident.
How the AWS side actually evaluates
DX publishes its route selection logic explicitly, and the order matters more than any individual attribute. The first thing AWS looks at on outbound traffic toward on-premises is the longest prefix match. Specificity wins over everything else. A
10.0.0.0/16 advertised from one metro and a 10.0.0.0/24 carved out of the same supernet from another metro will always send the matching /24 traffic through the metro that advertised it, regardless of what AS-path or community is set on the broader prefix. That is not a tuning knob you reach for last; it is the default behavior of the forwarding plane, and on DX it is the most powerful and most misused tool teams have.When specificity is tied across paths, AWS evaluates the local preference BGP community tags before AS-path. The published communities are
7224:7100 for low preference, 7224:7200 for medium, and 7224:7300 for high, with higher values winning. AS-path length comes next: when prefix length and local preference are equal, AWS prefers the shorter AS-path. The Multi-Exit Discriminator (MED) is evaluated only when the prior attributes are tied, and AWS itself recommends against relying on it given that priority order. Finally, when everything is equal, AWS forwards across the available paths using ECMP.The retailer's prepending strategy failed at the second step. Both paths had default local preference, so AS-path length was never the deciding factor — the routes were already considered tied before prepending got a vote. The lesson is uncomfortable but freeing. On AWS DX, if you want to truly steer return traffic, you steer it with local preference communities first and prefix specificity second. Prepending is the right tool only when both ends of the selection sit outside AWS-controlled logic — which is to say, on public virtual interfaces — and even then it carries its own caveats.
Communities are how you actually steer
The DX local preference communities are the cleanest expression of intent the protocol offers in this environment. Tagging the primary path's prefixes with
7224:7300 and the secondary with 7224:7100 gives you a deterministic active-passive split that survives both convergence events and any later prepending mistakes a peer might make. Tagging both with the same value, typically 7224:7200 , gives you a deterministic active-active across the paths. Either choice is more readable, more reviewable, and more revertable than a chain of AS-path manipulations.There is a second family of communities that controls scope rather than preference, and it matters most on public virtual interfaces.
7224:9100 tells AWS to keep the advertised prefix inside the local AWS Region. 7224:9200 widens it to all Regions on the same continent. 7224:9300 , or no tag at all, makes the prefix global across all public AWS Regions. Used carefully, these tags let an EMEA-anchored deployment avoid having its on-premises prefixes pulled into AWS routing tables in Regions where they have no business being used. Used carelessly, they can deny return paths the team thought they had.A subtlety on public virtual interfaces that catches teams off guard: AWS advertises every public prefix it sends you with the well-known NO_EXPORT community, and it treats every prefix it receives from you as if NO_EXPORT were set. The contract is one hop deep into the AWS network. Anything you were planning that depended on AWS re-advertising your prefixes onward through its peering edge to the wider internet is not going to work, and the resilience outcome you assumed will not exist.
AS-path prepending: where it works and where it doesn't
AS-path prepending is a legitimate tool, but it only carries weight when you are advertising into a peer that does not have a higher-priority lever to pull. On a private virtual interface where the AWS side will look at local preference first, prepending the on-premises advertisement does nothing unless both paths are already tied on local preference. On a public virtual interface, AS-path prepending is only supported when you peer with a public Autonomous System Number (ASN); a private ASN will have its private numbers stripped, which removes the prepending you thought you had applied.
Used in the right place, prepending is fine. As the default mechanism for steering DX traffic, it is the wrong tool, because it sits below local preference and longest-prefix match in the selection algorithm. The standard mistake is to reach for prepending because it feels familiar from internet edge designs, and to discover several months later that the team has been operating without any actual steering at all.
The prefix limits nobody likes
DX enforces hard caps on how many BGP prefixes a virtual interface will accept or advertise, and these caps are not negotiable. A private virtual interface accepts up to 100 prefixes from on-premises. A transit virtual interface attached to a Transit Gateway accepts up to 100 prefixes from on-premises and advertises a maximum of 200 prefixes from AWS to on-premises. The 200-prefix outbound limit is the one that bites large estates first: an organization with hundreds of Virtual Private Cloud (VPC) Classless Inter-Domain Routing (CIDR) blocks cannot expose them all natively over a single transit virtual interface, and Transit Gateway Connect over Generic Routing Encapsulation becomes the practical answer when that ceiling is reached.
Exceeding the limit does not gracefully degrade. The BGP session goes idle, the route stops being advertised, and the team is suddenly debugging what looks like a black hole. The right discipline is to summarize ruthlessly on the on-premises edge and to plan VPC CIDR allocations with the knowledge that they will eventually need to be representable inside these limits, not retrofitted around them.
The asymmetry that is by design
The hardest part of BGP traffic engineering on DX is accepting that AWS designs for tolerable asymmetry, while many on-premises networks do not. AWS will happily send outbound traffic over a different path than the one that delivered the inbound traffic, because ECMP and route selection are decoupled. Stateful firewalls, intrusion prevention systems, and Network Address Translation devices on-premises usually cannot tolerate that without either path pinning or session synchronization. The fix is rarely on the AWS side. It is on the on-premises side: collapse the active paths through a state-sharing firewall pair, or accept active-passive with communities and reserve the standby path for failover.
That trade-off is the through-line of every DX traffic engineering decision. The protocol gives you levers. The AWS-side selection algorithm decides which lever moves the load. The blast radius of getting it wrong is rarely the BGP session itself; it is the application that depends on consistent return paths and the regulator who eventually asks why a documented control failed silently for a quarter.
What's next
BGP gives the data plane its instructions. The next article steps back to the architectural question those instructions serve — when active-active across Regions is the right resilience outcome, when active-passive is more honest about the trade-offs, and how to build a decision matrix the team will actually live with under a regulator's eye.
Cristian Critelli is the EMEA Lead for Networking and Resilience Specialist Partner Solutions Architect at AWS focused on networking and resilience across EMEA. His book, Cloud Networking and Resilience (Apress), is available now.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article