Sub topic 6
Route tables, association, and propagation
This chapter covers how a transit gateway decides where to send a packet. It assumes you know CIDR blocks, subnets, and VPC route tables, and that you have already created a transit gateway and attached at least one VPC. The commands use the AWS CLI.
Two kinds of route tables
A VPC route table and a transit gateway route table are separate objects. They answer different questions.
- A VPC route table tells a subnet where to send traffic leaving the subnet. One entry can point at the transit gateway.
- A transit gateway route table tells the transit gateway where to send traffic that has already arrived on an attachment.
A packet crossing between two VPCs is checked against both. First the source subnet's route table sends it to the transit gateway. Then the transit gateway route table that is associated with the source attachment chooses the destination attachment. Finally the destination VPC's route table handles the return path.
Association: which table an attachment uses
An association links one attachment to one transit gateway route table. Traffic that enters the transit gateway from that attachment is looked up in that table.
- Each attachment can be associated with only one route table.
- A route table can have many attachments associated with it.
- An attachment with no association has no table to consult, so traffic arriving from it is dropped.
Association controls the outbound view of an attachment. It answers the question "where can traffic from this attachment go?"
Propagation: how routes get into a table
A route table needs entries. You can add them in two ways.
- Static routes are entries you create by hand with a CIDR and a target attachment. You can also create a blackhole route that drops matching traffic.
- Propagated routes are entries that an attachment adds automatically. When you enable propagation from an attachment into a route table, the attachment's CIDR is installed as a route pointing at that attachment.
For a VPC attachment, the propagated route is the VPC's CIDR block or blocks. For VPN and Direct Connect gateway attachments, the propagated routes come from what the on-premises side advertises through BGP.
Propagation controls the inbound view of an attachment. It answers the question "who can reach this attachment?"
A table can receive propagation from many attachments, and one attachment can propagate into many tables. The choice is independent of association.
| Concept | Relationship | Question it answers |
|---|---|---|
| Association | One attachment to one route table | Where can traffic from this attachment go? |
| Propagation | One attachment to many route tables | Who can send traffic to this attachment? |
| Static route | Entry typed by an operator | Which extra destinations should be reachable? |
Default tables and why this tutorial turns them off
When you create a transit gateway, AWS can create a default route table. With default association enabled, every new attachment is associated with it. With default propagation enabled, every attachment propagates into it. The result is a flat network where all attachments reach each other.
That is convenient for a lab. It is a poor fit when you want to isolate production from development. The first code example in this tutorial creates the gateway with both defaults disabled, so nothing is associated or propagated until you say so.
aws ec2 create-transit-gateway \
--description "hub" \
--options AmazonSideAsn=64512,DefaultRouteTableAssociation=disable,DefaultRouteTablePropagation=disableYou can still change the setting later with modify-transit-gateway. The change affects attachments created afterward. Existing associations stay as they are.
Configuring a route table
The following commands create a table, associate an attachment with it, and propagate the same attachment's CIDR into it. Replace the IDs with your own.
aws ec2 create-transit-gateway-route-table \
--transit-gateway-id tgw-0123456789abcdef0
aws ec2 associate-transit-gateway-route-table \
--transit-gateway-route-table-id tgw-rtb-0123456789abcdef0 \
--transit-gateway-attachment-id tgw-attach-0123456789abcdef0
aws ec2 enable-transit-gateway-route-table-propagation \
--transit-gateway-route-table-id tgw-rtb-0123456789abcdef0 \
--transit-gateway-attachment-id tgw-attach-0123456789abcdef0In this example the same attachment is both associated with the table and propagating into it. That is a valid setup for a single shared table, but it is only one of several patterns. Often the table an attachment is associated with is different from the tables it propagates into.
To see what the table holds, search it for active routes:
aws ec2 search-transit-gateway-routes \
--transit-gateway-route-table-id tgw-rtb-0123456789abcdef0 \
--filters "Name=state,Values=active"Each result shows the destination CIDR, the type (static or propagated), the state, and the attachment that the route targets. Check the Type field when you debug. A static route that you forgot about can hide the propagated route you expected to see.
Route selection rules
When several entries match a destination, the transit gateway picks one in this order:
- The most specific prefix wins. A
/24beats a/16. - If the prefixes are equal, a static route beats a propagated route.
- If equal-length propagated routes remain, VPC attachments are preferred over Direct Connect gateway attachments, then Site-to-Site VPN attachments, then peering attachments.
Two VPCs with the same CIDR propagating into the same table is a conflict. The table cannot hold both as active propagated routes for the same prefix in a useful way, and traffic goes to only one. Overlapping ranges are covered in a later chapter.
A worked example
Suppose you have three VPCs.
| VPC | CIDR | Role |
|---|---|---|
| A | 10.0.0.0/16 | Application |
| B | 10.1.0.0/16 | Application |
| C | 10.2.0.0/16 | Shared tools |
You want A, B, and C to reach each other. The simplest design is one route table named shared.
- Create the
sharedtable. - Associate attachments A, B, and C with
shared. - Enable propagation from A, B, and C into
shared.
The table then contains three propagated routes, one per VPC CIDR. Traffic from any attachment is looked up in shared and forwarded to the right target.
Now suppose you want A and B to reach C but not each other. Use two tables.
apps: A and B are associated with it. Only C propagates into it. The table holds only the route for 10.2.0.0/16.tools: C is associated with it. A and B propagate into it. The table holds the routes for 10.0.0.0/16 and 10.1.0.0/16.
A sends to B, finds no matching route in apps, and the packet is dropped. A sends to C, finds the route, and the packet goes through. The return traffic from C is looked up in tools, which contains A and B. This is the basis for the segmentation pattern in a later chapter.
Common errors
- Traffic is dropped even though routes exist. Check that the source attachment has an association. Propagation alone does not give it a table to look up.
- Return traffic fails. Routing must work in both directions. The destination attachment's associated table must contain a route back to the source CIDR.
- A new VPC cannot reach anything. If default association is disabled, a new attachment starts with no association and no propagation. Configure both explicitly.
- The VPC side is missing. The transit gateway tables can be correct while the subnet route table has no entry for the remote CIDR. That entry is the subject of the next chapter.
- Security groups or network ACLs block the traffic. Routing only decides the path. Filtering still applies at each end.
- Propagation was enabled after the fact. Enabling propagation adds the route. Disabling it removes the propagated route, so traffic that relied on it stops.
Limits worth knowing
Quotas apply to the number of route tables per transit gateway and routes per table. They change over time, so check the current Amazon VPC Transit Gateway quotas page before you design a large environment. Propagated routes count toward the route limit, so a VPN that advertises many prefixes can use up a table.
Exercise
VPC X and VPC Y both have attachments to a transit gateway with default association and propagation disabled. Attachment X is associated with table T1. Attachment Y propagates into T1 but has no association. Can an instance in X reach an instance in Y, and can Y reach X?
Show answer
X can send to Y at the transit gateway level, because X is associated with T1 and T1 holds a propagated route for Y's CIDR. Y cannot send to X. Y has no association, so traffic arriving from Y has no route table to consult and is dropped. Replies from Y to X also fail for the same reason. To fix it, associate Y with a table that contains a route to X's CIDR, for example by propagating X into that table. Subnet route entries and security rules must also allow the traffic.
Exercise
Two route table entries match the destination 10.1.5.9. One is a propagated route for 10.1.0.0/16 and the other is a static route for 10.1.5.0/24. Which one does the transit gateway use, and why?
Show answer
The static route for 10.1.5.0/24 is used. Route selection prefers the most specific prefix first, and a /24 is more specific than a /16. The static versus propagated rule only applies when the prefix lengths are equal.