Question: How can I use BGP communities to influence the preferred routing path on Direct Connect links from AWS to my network?

I want to use Border Gateway Protocol (BGP) communities to influence the preferred routing path on AWS Direct Connect links from AWS to my network.

Short descriptionTo configure private and transit virtual interfaces to prioritize which interface AWS uses to route traffic to your network, use the AS_PATH attribute. Direct Connect also supports local preference BGP community tags to control the route preference of traffic on private and transit virtual interfaces.Note: Local preference BGP community tags are evaluated before the AS_PATH attribute.

ResolutionCommunity tagsDirect Connect supports the following local preference BGP communities:7224:7100 Low preference7224:7200 Medium preference7224:7300 High preferenceDirect Connect evaluates local preference BGP community tags from lowest to highest preference. For each prefix that you advertise over a BGP session, you can apply a community tag to indicate the associated path's priority for returning traffic. Similarly, when you advertise from on-premises to AWS, you can prepend additional AS_PATH attributes to the prefixes. Direct Connect prioritizes the path with the fewest AS_PATH attributes for returning traffic.The following scenario is an example use case:You have two virtual interfaces A and B and advertising prefixes 10.10.10.0/24 and 10.20.20.0/24 to AWS.You want virtual interface A to be preferred for traffic to network 10.10.10.0/24.You want virtual interface B to be preferred for traffic to network 10.20.20.0/24.In this case, you can use local preference community tags:Apply higher preference tag 7224:7300 to prefix 10.10.10.0/24 on the BGP session in virtual interface A.Apply higher preference tag 7224:7300 to prefix 10.20.20.0/24 on the BGP session in virtual interface B.Note:For private virtual interfaces, if you don't use BGP community tags to specify local preference, then the outbound routing behavior defaults to an AWS Region. In this case, the behavior is based on the Direct Connect locations' relative distance to the originating Region. If the relative distance costs aren't equal, then Autonomous System (AS) prepending can't influence routing behavior. Direct Connect evaluates the lowest distance relative cost before AS_PATH prepending.To load balance traffic across multiple AWS Direct Connect connections, apply the same community tag across the prefixes for the connections.Configuring AS_PATH and BGP community attributesYou must configure AS_PATH prepending and BGP community tags on an on-premises router. Advertise the prefixes from this router to the Direct Connect router. Because you can use any routing device for this task, you must refer to a configuration that's specific to your vendor's router. See the following external documentation for vendors that are commonly used for on-premises routers:Configure AS_PATH prepending on Juniper.Configure AS_PATH prepending on PaloAlto.Configure AS_PATH prepending on Cisco.Configure your BGP community on Juniper.Configure your BGP community on PaloAlto.Configure your BGP community on Cisco.The following example configuration prepends an AS_PATH for prefix 10.0.0.0/8 on a Cisco router and advertise to AWS:Router(config)#access-list 10 permit 10.0.0.0 0.255.255.255Router(config)#route-map cisco permit 10Router(config-route-map)#match ip address 10Router(config-route-map)#set as-path prepend 650014 650014Router(config-route-map)#exitRouter(config)#route-map cisco permit 20Router(config-route-map)#exitRouter(config)#router bgp LOCAL\_ASRouter(config-router)#neighbor NEIGHBOR\_IP route-map cisco outRouter(config-router)#endThe following example configuration advertises prefix 10.0.0.0/8 with the BGP community tag 7224:7300 from a Cisco router to AWS:Router(config)#access-list 10 permit 10.0.0.0 0.255.255.255  Router(config)#route-map cisco permit 10  Router(config-route-map)#match ip address 10  Router(config-route-map)#set community 7224:7300  Router(config-route-map)#exit  Router(config)#route-map cisco permit 20  Router(config-route-map)#exit  Router(config)#router bgp LOCAL\_AS  Router(config-router)#neighbor NEIGHBOR\_IP send-community  Router(config-router)#neighbor NEIGHBOR\_IP route-map cisco out  Router(config-router)#endNote: In these examples, replace LOCAL_AS and NEIGHBOR_IP with your values.

Related informationPublic virtual interface BGP communitiesRouting policies and BGP communitiesHow can I use BGP communities to control the routes advertised and received over the AWS public virtual interface with Direct Connect?