Home / AWS

AWSCheat sheetAdvanced

AWS Direct Connect BGP traffic engineering cheat sheet: communities, prefix limits and asymmetric paths

Steer Direct Connect traffic in both directions with BGP communities, avoid the prefix limits that drop a session, and prove failover before you need it.

Deepak Bhardwaj7 min read

Applies toAWS Direct Connect private, transit and public virtual interfaces; Direct Connect gateway; Cisco IOS/IOS-XE examples

Your Direct Connect sessions are up, but traffic uses the wrong circuit, returns on a different one, or a session drops after a routing change. This sheet covers the controls AWS honours, the limits that bite, and how to test the result.

One rule explains most problems: each side chooses its own egress path. What you advertise steers traffic from AWS to you. What you do with received routes steers traffic from you to AWS. Configure both.

Quick diagnosis

Symptom Likely cause Fix
AWS returns traffic on the backup circuit No local preference community, so the Region default or ECMP decides Tag primary 7224:7300, backup 7224:7100
AS_PATH prepending has no effect Local preference or a longer prefix decides first Make prefixes equal length and use communities
Communities set but ignored Router isn't sending standard communities neighbor x send-community
Session goes down after a new site is added Prefix allocation exceeded Summarise, or raise the allocation
Stateful firewall drops half of the flows Different paths chosen in each direction Match primary and backup on both sides
On-premises never learns a new VPC CIDR over a transit VIF CIDR not covered by allowed prefixes Update the gateway association

How AWS picks the path back to you

For private and transit VIFs, AWS evaluates in this order:

  1. Longest prefix match
  2. Local preference (your community tag, or the Region-based default)
  3. AS_PATH length
  4. MED, which AWS recommends not relying on
  5. ECMP across equal paths

Longest prefix comes first, so a /24 leaked on the backup beats a /16 on the primary whatever the tags say. Check for leaked specifics before touching anything else.

Local preference communities (private and transit VIFs)

Community Preference Use
7224:7100 Low Passive circuit
7224:7200 Medium Same value on all circuits for active/active
7224:7300 High Primary circuit

Apply exactly one per prefix. They must be standard communities: an extended community is accepted without an error but not evaluated.

Without a tag, AWS prefers Direct Connect locations associated with the same Region as the destination VPC. That default is evaluated before AS_PATH, so prepending on a local circuit doesn't move traffic to a remote-Region location.

Scope communities (public VIFs)

Direction Community Meaning
You to AWS 7224:9100 Local Region only
You to AWS 7224:9200 Continent
You to AWS 7224:9300 Global; also the default without a tag
AWS to you 7224:8100 Route from the same Region as the location
AWS to you 7224:8200 Route from the same continent

Use inbound filters on 7224:8100 and 7224:8200 to keep the public table small. With a private ASN, AWS replaces it with 7224 and strips your prepending, so prepending needs a public ASN.

Warning

Public VIF routing affects traffic between your public prefixes and AWS public services, which can include other customers' workloads on AWS. If the same prefixes are also used on your internet edge, check for asymmetric return through stateful firewalls before widening the scope.

Router configuration: active/passive

Addresses and ASNs are examples. This sets both directions: OUT controls AWS to you, IN controls you to AWS.

ip bgp-community new-format
ip prefix-list ONPREM-OUT seq 10 permit 10.20.0.0/16
!
route-map DX-PRIMARY-OUT permit 10
 match ip address prefix-list ONPREM-OUT
 set community 7224:7300
route-map DX-PRIMARY-IN permit 10
 set local-preference 300
!
route-map DX-BACKUP-OUT permit 10
 match ip address prefix-list ONPREM-OUT
 set community 7224:7100
route-map DX-BACKUP-IN permit 10
 set local-preference 100
!
router bgp 65010
 neighbor 169.254.10.1 remote-as 64512
 neighbor 169.254.20.1 remote-as 64512
 address-family ipv4
  neighbor 169.254.10.1 activate
  neighbor 169.254.10.1 send-community
  neighbor 169.254.10.1 route-map DX-PRIMARY-OUT out
  neighbor 169.254.10.1 route-map DX-PRIMARY-IN in
  neighbor 169.254.20.1 activate
  neighbor 169.254.20.1 send-community
  neighbor 169.254.20.1 route-map DX-BACKUP-OUT out
  neighbor 169.254.20.1 route-map DX-BACKUP-IN in

If the circuits end on different routers, those routers need iBGP between them (or an equivalent IGP policy), because local preference isn't carried by eBGP. Refresh softly and confirm what is sent:

clear ip bgp 169.254.10.1 soft out
show ip bgp neighbors 169.254.10.1 advertised-routes
show ip bgp neighbors 169.254.10.1 routes

Tip

During planned maintenance AWS prepends its ASN three times on advertised routes and adds 7224:2200 and 65535:0 (GRACEFUL_SHUTDOWN). Your inbound local preference overrides the prepend, so match one of these communities in an earlier route-map sequence and lower local preference. Otherwise a static primary/backup policy ignores the signal.

ip community-list standard DX-MAINT permit 7224:2200
route-map DX-PRIMARY-IN permit 5
 match community DX-MAINT
 set local-preference 50

Prefix limits

Going over the allocation isn't a filter. It takes the BGP session down.

Direction Limit
You to AWS, private or transit VIF 100 per address family by default; can be allocated up to 1,000
You to AWS, public VIF 1,000
AWS to you, transit VIF 200 per transit gateway, IPv4 and IPv6 combined

These can change; check the current quotas. Read the allocation and raise it from the connection's pool:

aws directconnect describe-virtual-interfaces \
  --query 'virtualInterfaces[].{id:virtualInterfaceId,type:virtualInterfaceType,state:virtualInterfaceState,v4Alloc:prefixPoolAllocatedCountIpv4,peers:bgpPeers[].{af:addressFamily,bgp:bgpStatus}}'

aws directconnect update-virtual-interface-attributes \
  --virtual-interface-id dxvif-ffabc123 \
  --prefix-pool-allocated-count-ipv4 300

Support for the attribute depends on your CLI version, so update the CLI if it's rejected. Also set a maximum outbound set with a strict prefix list on your router. Redistributing an IGP into BGP without one is the usual cause of a mass withdrawal.

Allowed prefixes mean different things

aws directconnect describe-direct-connect-gateway-associations \
  --direct-connect-gateway-id <dxgw-id> \
  --query 'directConnectGatewayAssociations[].{gw:associatedGateway.id,type:associatedGateway.type,allowed:allowedPrefixesToDirectConnectGateway[].cidr}'
  • Virtual private gateway: the list is a filter. A VPC CIDR is advertised when the list covers it.
  • Transit gateway: the list is what gets advertised, whether or not a VPC with that CIDR exists. A typo here blackholes traffic, and a summary can attract traffic for unused space.

Observe it

aws cloudwatch list-metrics --namespace AWS/DX \
  --metric-name VirtualInterfaceBgpPrefixesAccepted

aws cloudwatch get-metric-statistics --namespace AWS/DX \
  --metric-name VirtualInterfaceBgpPrefixesAccepted \
  --dimensions Name=VirtualInterfaceId,Value=dxvif-ffabc123 Name=IpAddressFamily,Value=ipv4 \
  --start-time "$(date -u -d '24 hours ago' +%FT%TZ)" \
  --end-time "$(date -u +%FT%TZ)" --period 300 --statistics Minimum Maximum

Alarm on these:

  • VirtualInterfaceBgpStatus below 1.
  • VirtualInterfaceBgpPrefixesAccepted above about 80% of the allocation.
  • VirtualInterfaceBgpPrefixesAccepted falling sharply. The session can stay up while a bad filter withdraws your routes.
  • Egress bits on the passive VIF above its normal baseline. This is the best detector of silent asymmetry.

Test failover

Caution

This test takes the BGP session down for real. Confirm the other path is up and carries the same prefixes first, and don't run it during Direct Connect maintenance.

aws directconnect start-bgp-failover-test \
  --virtual-interface-id dxvif-ffabc123 \
  --test-duration-in-minutes 15

# Roll back early
aws directconnect stop-bgp-failover-test --virtual-interface-id dxvif-ffabc123

aws directconnect list-virtual-interface-test-history \
  --virtual-interface-id dxvif-ffabc123

Always set the duration: the default is 180 minutes. The test must run from the account that owns the VIF. It proves path selection, not detection speed, because BGP is brought down administratively. To measure detection of a silent failure, enable BFD on your router and test by shutting the path in a way that leaves the interface up.

Prevent it next time

  • Generate route maps for both directions from one source, so primary and backup can't disagree.
  • Advertise the same prefix lengths on every circuit, and reject leaked specifics outbound.
  • Use an explicit community on every prefix instead of the Region default.
  • Review headroom against the allocation before each site migration.
  • Run a failover test per VIF each quarter and compare observed paths with the design.
  • Size each circuit to carry the full load alone. Active/active at more than half utilisation is not redundant.