Sub topic 12
Route 53 Resolver endpoints for hybrid DNS
This chapter assumes you know private hosted zones, basic VPC networking (subnets, security groups), and a private link between your network and AWS, such as Site-to-Site VPN or Direct Connect. It also assumes you can read aws CLI commands.
The problem hybrid DNS solves
Every VPC has a built-in DNS resolver called Route 53 Resolver. It answers queries from instances in the VPC, including names in private hosted zones. It has two limits:
- Your on-premises network cannot send queries to it, because it has no address reachable from outside the VPC.
- It does not know your corporate DNS zones, such as
corp.example.com, which live on your own DNS servers.
Resolver endpoints fix both limits. An endpoint is a set of elastic network interfaces (ENIs) that Route 53 places in your subnets.
Inbound and outbound endpoints
| Endpoint | Direction of queries | Typical use |
|---|---|---|
| Inbound | On-premises to VPC | On-premises servers resolve private hosted zone names |
| Outbound | VPC to on-premises | EC2 instances resolve names served by corporate DNS |
An inbound endpoint gives you IP addresses inside your VPC. You configure your on-premises DNS servers to forward queries for your AWS names to those addresses. An outbound endpoint sends queries from the VPC to the DNS server IPs you choose. Which names go there is decided by forwarding rules.
Create the endpoints
Both endpoint types need a security group. The inbound endpoint's group must allow TCP and UDP port 53 from your on-premises ranges. The outbound endpoint's group must allow port 53 traffic out to your DNS servers. Each endpoint needs at least two IP addresses, and you should place them in different Availability Zones.
aws route53resolver create-resolver-endpoint \
--creator-request-id "inbound-$(date +%s)" \
--name hybrid-inbound \
--direction INBOUND \
--security-group-ids sg-0123456789abcdef0 \
--ip-addresses SubnetId=subnet-0aaa1111bbb22222c SubnetId=subnet-0ddd3333eee44444fOmitting Ip= lets Route 53 choose a free address in each subnet. The command returns the endpoint ID and, once it is operational, the assigned IPs. Use get-resolver-endpoint and list-resolver-endpoint-ip-addresses to read them, then give those IPs to your on-premises DNS administrators.
Forward VPC queries to your own DNS
For the outbound direction, create an outbound endpoint with --direction OUTBOUND, then create a forwarding rule and attach it to a VPC.
aws route53resolver create-resolver-rule \
--creator-request-id "rule-$(date +%s)" \
--name corp-forward \
--rule-type FORWARD \
--domain-name corp.example.com \
--resolver-endpoint-id rslvr-out-0123456789abcdef0 \
--target-ips Ip=10.1.0.10,Port=53 Ip=10.1.1.10,Port=53
aws route53resolver associate-resolver-rule \
--resolver-rule-id rslvr-rr-0123456789abcdef0 \
--vpc-id vpc-0123456789abcdef0After association, any query from that VPC for corp.example.com or a subdomain goes through the outbound endpoint to the two target servers. All other names resolve as before.
Operating notes
- Rules can be shared across accounts with AWS Resource Access Manager, so one outbound endpoint can serve many VPCs.
- Endpoints cost an hourly charge per ENI, plus a charge per query. Two IPs per endpoint is the minimum, so size for availability rather than cutting to one.
- Each ENI handles a limited query rate. High-volume workloads need more IPs on the endpoint.
- If a forwarded name fails, test from an instance with
dig corp.example.com. Then check the security groups, the route to your network, and whether the on-premises server answers when queried directly.
Exercise
Servers in your data center must resolve db.internal.example.com, which is in a private hosted zone associated with your VPC. Which endpoint type do you create, and what do you configure on-premises?
Show answer
Create an inbound Resolver endpoint with IPs in at least two subnets. Allow TCP and UDP port 53 from your on-premises ranges in its security group. Then configure your on-premises DNS servers to forward queries for internal.example.com to the endpoint's IP addresses.