Simplify DNS management in a multi-account environment with Route 53 Resolver
September 27, 2021: In the section “Third use case,” we updated step 3 to improve clarity.
April 15, 2021: In the section “Third use case,” we updated the diagram and steps for clarity.
April 2, 2021: In the section “Step 1: Set up a centralized DNS account,” we updated step 4.
June 5, 2019: We updated all of the figures in the post for clarity and added two paragraphs in the “Additional considerations and limitations” section.
In a previous post, I showed you a solution to implement central DNS in a multi-account environment that simplified DNS management by reducing the number of servers and forwarders you needed when implementing cross-account and AWS-to-on-premises domain resolution. With the release of the Amazon Route 53 Resolver service, you now have access to a native conditional forwarder that will simplify hybrid DNS resolution even more.
In this post, I’ll show you a modernized solution to centralize DNS management in a multi-account environment by using Route 53 Resolver. This solution allows you to resolve domains across multiple accounts and between workloads running on AWS and on-premises without the need to run a domain controller in AWS.
My solution will show you how to solve three primary use-cases for domain resolution:
- Resolving on-premises domains from workloads running in your VPCs.
- Resolving private domains in your AWS environment from workloads running on-premises.
- Resolving private domains between workloads running in different AWS accounts.
The following diagram explains the high-level full architecture.
In this architecture:
- This is the Amazon-provided default DNS server for the central DNS VPC, which we’ll refer to as the DNS-VPC. This is the second IP address in the VPC CIDR range (as illustrated, this is 172.27.0.2). This default DNS server will be the primary domain resolver for all workloads running in participating AWS accounts.
- This shows the Route 53 Resolver endpoints. The inbound endpoint will receive queries forwarded from on-premises DNS servers and from workloads running in participating AWS accounts. The outbound endpoint will be used to forward domain queries from AWS to on-premises DNS.
- This shows conditional forwarding rules. For this architecture, we need two rules, one to forward domain queries for onprem.private zone to the on-premises DNS server through the outbound endpoint, and a second rule to forward domain queries for awscloud.private to the resolver inbound endpoint in DNS-VPC.
- This indicates that these two forwarding rules are shared with all other AWS accounts through AWS Resource Access Manager and are associated with all VPCs in these accounts.
- This shows the private hosted zone created in each account with a unique subdomain of awscloud.private.
- This shows the on-premises DNS server with conditional forwarders configured to forward queries to the awscloud.private zone to the IP addresses of the Resolver inbound endpoint.
Note: This solution doesn’t require VPC-peering or connectivity between the source/destination VPCs and the DNS-VPC.
How it works
Now, I’m going to show how the domain resolution flow of this architecture works according to the three use-cases I’m focusing on.
First use case
First, I’ll look at resolving on-premises domains from workloads running in AWS. If the server with private domain host1.acc1.awscloud.private attempts to resolve the address host1.onprem.private, here’s what happens:
- The DNS query will route to the default DNS server of the VPC that hosts host1.acc1.awscloud.private
- Because the VPC is associated with the forwarding rules shared from the central DNS account, these rules will be evaluated by the default Amazon-provided DNS in the VPC.
- In this example, one of the rules indicates that queries for onprem.private should be forwarded to an on-premises DNS server. Following this rule, the query will be forwarded to an on-premises DNS server.
- The forwarding rule is associated with the Resolver outbound endpoint, so the query will be forwarded through this endpoint to an on-premises DNS server.
In this flow, the DNS query that was initiated in one of the participating accounts has been forwarded to the centralized DNS server which, in turn, forwarded this to the on-premises DNS.
Second use case
Next, here’s how on-premises workloads will be able to resolve private domains in your AWS environment:
In this case, the query for host1.acc1.awscloud.private is initiated from an on-premises host. Here’s what happens next:
- The domain query is forwarded to on-premises DNS server.
- The query is then forwarded to the Resolver inbound endpoint via a conditional forwarder rule on the on-premises DNS server.
- The query reaches the default DNS server for DNS-VPC.
- Because DNS-VPC is associated with the private hosted zone acc1.awscloud.private, the default DNS server will be able to resolve this domain.
In this case, the DNS query has been initiated on-premises and forwarded to centralized DNS on the AWS side through the inbound endpoint.
Third use case
Finally, you might need to resolve domains across multiple AWS accounts. Here’s how you could achieve this:
Let’s say that host1 in host1.acc1.awscloud.private attempts to resolve the domain host2.acc2.awscloud.private. Here’s what happens:
- The domain query is sent to the default DNS server for the VPC hosting source machine (host1).
- Because the VPC is associated with the shared forwarding rules, these rules will be evaluated.
- A rule indicates that queries for awscloud.private zone should be forwarded to the Inbound Endpoints (via the Outbound Endpoint) in DNS-VPC.
- The Outbound Endpoint then forwards the DNS query to the target IPs. In this example, the target IPs are the IP addresses of the Inbound Endpoint.
- Because DNS-VPC is associated with the acc2.awscloud.private hosted zone, the default DNS will use auto-defined rules to resolve this domain.
This use case explains the AWS-to-AWS case where the DNS query has been initiated on one participating account and forwarded to central DNS for resolution of domains in another AWS account. Now, I’ll look at what it takes to build this solution in your environment.
How to deploy the solution
I’ll show you how to configure this solution in four steps:
- Set up a centralized DNS account.
- Set up each participating account.
- Create private hosted zones and Route 53 associations.
- Configure on-premises DNS forwarders.
Step 1: Set up a centralized DNS account
In this step, you’ll set up resources in the centralized DNS account. Primarily, this includes the DNS-VPC, Resolver endpoints, and forwarding rules.
- Create a VPC to act as DNS-VPC according to your business scenario, either using the web console or from an AWS Quick Start. You can review common scenarios in the Amazon VPC user guide; one very common scenarios is a VPC with public and private subnets.
- Create resolver endpoints. You need to create an outbound endpoint to forward DNS queries to on-premises DNS and an inbound endpoint to receive DNS queries forwarded from on-premises workloads and other AWS accounts.
- Create two forwarding rules. The first rule is to forward DNS queries for zone onprem.private to your on-premises DNS server IP addresses, and the second rule is to forward DNS queries for zone awscloud.private to the IP addresses of the resolver inbound endpoint.
- After creating the rules, associate the rule for zone onprem.private with DNS-VPC that was created in step #1 (you don’t need to associate the other forwarding rule with DNS-VPC). This will allow the Route 53 Resolver to start forwarding domain queries accordingly.
- Finally, you need to share the two forwarding rules with all participating accounts. To do that, you’ll use AWS Resource Access Manager and you can share the rules with your entire AWS Organization or with specific accounts.
Note: To be able to forward domain queries to your on-premises DNS server, you need connectivity between your data center and DNS-VPC, which could be established either using site-to-site VPN or AWS Direct Connect.
Step 2: Set up participating accounts
For each participating account, you need to configure your VPCs to use the shared forwarding rules, and you need to create a private hosted zone for each account.
- Accept the shared rules from AWS Resource Access Manager. This step is not required if the rules were shared to your AWS Organization. Then, associate the forwarding rules with the VPCs that host your workloads in each account. Once associated, the resolver will start forwarding DNS queries according to the rules.
At this point, you should be able to resolve on-premises domains from workloads running in any VPC associated with the shared forwarding rules. To create private domains in AWS, you need to create Private Hosted Zones.
Step 3: Create private hosted zones
In this step, you need to create a private hosted zone in each account with a subdomain of awscloud.private. Use unique names for each private hosted zone to avoid domain conflicts in your environment (for example, acc1.awscloud.private or dev.awscloud.private).
- Create a private hosted zone in each participating account with a subdomain of awscloud.private and associate it with VPCs running in that account.
- Associate the private hosted zone with DNS-VPC. This allows the centralized DNS-VPC to resolve domains in the private hosted zone and act as a DNS resolver between AWS accounts.
Because the private hosted zone and DNS-VPC are in different accounts, you need to associate the private hosted zone with DNS-VPC. To do that, you need to create authorization from the account that owns the private hosted zone and accept this authorization from the account that owns DNS-VPC. You can do that using AWS CLI:
- In each participating account, create the authorization using the private hosted zone ID, the region, and the VPC ID that you want to associate (DNS-VPC).
- In the centralized DNS account, associate the DNS-VPC with the hosted zone in each participating account.
Step 4: Configure on-premises DNS forwarders
To be able to resolve subdomains within the awscloud.private domain from workloads running on-premises, you need to configure conditional forwarding rules to forward domain queries to the two IP addresses of resolver inbound endpoints that were created in the central DNS account. Note that this requires connectivity between your data center and DNS-VPC, which could be established either using site-to-site VPN or
AWS Direct Connect.
Additional considerations and limitations
Thanks to the flexibility of Route 53 Resolver and conditional forwarding rules, you can control which queries to send to central DNS and which ones to resolve locally in the same account. This is particularly important when you plan to use some AWS services, such as AWS PrivateLink or Amazon Elastic File System (EFS) because domain names associated with these services need to be resolved local to the account that owns them.
I recommend that you resolve domains local to the account when possible; for example, for private domains in the private hosted zones in the same account. To do that, you can create conditional forwarding rules local to the account, use “system” for rule type, and associate these rules with your VPCs.
Note about limits on Route 53 Resolver: Route 53 resolver has limit of 10,000 queries per second per IP Address on an endpoint. If you have a workload that requires higher limits, consider forwarding these queries to a suitably configured local DNS Server running on an EC2 instance. Read more about service limits here.
In this section, I will name two use-cases that require additional considerations.
- Interface VPC Endpoints (AWS PrivateLink)
When you create an AWS PrivateLink interface endpoint, AWS generates endpoint-specific DNS hostnames that you can use to communicate with the service. For AWS services and AWS Marketplace partner services, you can optionally enable private DNS for the endpoint. This option associates a private hosted zone with your VPC. The hosted zone contains a record set for the default DNS name for the service (for example, ec2.us-east-1.amazonaws.com) that resolves to the private IP addresses of the endpoint network interfaces in your VPC. This enables you to make requests to the service using its default DNS hostname instead of the endpoint-specific DNS hostnames.
If you use private DNS for your endpoint, you have to resolve DNS queries to the endpoint local to the account and use the default DNS provided by AWS. So, in this case, I recommend that you resolve domain queries in amazonaws.com locally and not forward these queries to central DNS.
- Mounting EFS with a DNS name
You can mount an Amazon EFS file system on an Amazon EC2 instance using DNS names. The file system DNS name automatically resolves to the mount target’s IP address in the Availability Zone of the connecting Amazon EC2 instance. To be able to do that, the VPC must use the default DNS provided by Amazon to resolve EFS DNS names.
If you plan to use EFS in your environment, I recommend that you resolve EFS DNS names locally and avoid sending these queries to central DNS because clients in that case would not receive answers optimized for their availability zone, which might result in higher operation latencies and less durability.
In this post, I introduced a simplified solution to implement central DNS resolution in a multi-account and hybrid environment. This solution uses AWS Route 53 Resolver, AWS Resource Access Manager, and native Route 53 capabilities and it reduces complexity and operations effort by removing the need for custom DNS servers or forwarders in AWS environment.
If you have feedback about this blog post, submit comments in the Comments section below. If you have questions about this blog post, start a new thread on in the AWS forums.
Want more AWS Security how-to content, news, and feature announcements? Follow us on Twitter.