AWS: Route53 Private Hosted Zones — hiding domains from the Internet
Tags: security, aws, dns
Published: 2021-07-29 09:22:36

---
title: AWS: Route53 Private Hosted Zones — hiding domains from the Internet
published: true
date: 2021-07-26 08:09:37 UTC
tags: security,aws,dns
canonical_url: https://rtfm.co.ua/en/aws-route53-private-hosted-zones-hiding-domains-from-the-internet
---

### AWS: Route53 Private Hosted Zones — hiding domains from the Internet

![](https://cdn-images-1.medium.com/max/1024/1*8QppZuMnRQSngTE4H4UqzA.png)

[Private Hosted Zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-private.html) in AWS Route53 allows to limit access to DNS records of a domain, thus making it inaccessible for the [DNS Enumeration](https://resources.infosecinstitute.com/topic/dns-enumeration-techniques-in-linux/) (or DNS brute-force), when an attacker checks for available records in a domain to know endpoints list to check them for vulnerabilities.

For such attacks, there is a lot of utilities such as [DNSEnum](https://github.com/fwaeytens/dnsenum), [DNSRecon](https://github.com/darkoperator/dnsrecon), [Fierce](http://ha.ckers.org/fierce/), or even a well-known Nmap with the [dns-brute](https://nmap.org/nsedoc/scripts/dns-brute.html) script.

The idea behind using private domain zones is that they can be reached from inside of only a limited set of VPCs in an AWS account, but they can not be accessed from the Internet.

### AWS VPC DNS

At first, let’s check how DNS is working in AWS VPC: in each VPC we have an address _\*.0.1_ — it is its Gateway, and another address is the _\*.0.2_ — it is the default DNS of a VPC.

For example, we have a VPC with the 10.0.6.0/24 CIDR. Thus, for this VPC we can reach the 10.0.6.2 to get information about a domain:

```
admin@bttrm-stage-console:~$ dig @10.0.6.2 ya.ru +short
87.250.250.242
```

This is the default DNS for services in an AWS VPC, although it can be configured for your own.

In our case, we have dnsmasq running on some of our old servers, and applications first will try to get information from it, and only then will go to the VPC's DNS:

```
admin@bttrm-stage-console:~$ cat /etc/resolv.conf
domain us-east-2.compute.internal
search us-east-2.compute.internal
nameserver 127.0.0.1
nameserver 10.0.6.2
nameserver 1.1.1.1
```

See more in the [DNS: установка BIND, DNS Load Balancing и network-based routing через view](https://rtfm.co.ua/dns-ustanovka-bind-dns-load-balancing-i-network-based-routing-cherez-view/#DNS_AWS), and [DNS: dnsmasq и порядок разрешения домён из resolv.conf](https://rtfm.co.ua/dns-dnsmasq-i-poryadok-razresheniya-domyon-iz-resolv-conf/) posts (both in Rus), or in the documentation — [Resolving DNS queries between VPCs and your network](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver.html).

Keep in mind that to make DNS in a VPC working, this VPC must have options `enableDnsHostnames` and `enableDnsSupport` enabled. Also, there are some limitations for the Route 53 health checks and routing policies. See more at [Considerations when working with a private hosted zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zone-private-considerations.html).

### AWS Route53 Private Hosted Zone

Now, when we know how DNS in AWS VPC is working, let’s create a private DNS zone.

Go to the Route53, create a new zone, set its type to the _Private hosted zone_:

![](https://cdn-images-1.medium.com/max/831/0*0h2Ck3kzn5O2EquU.png)

Below, you’ll see new options available to select AWS Regions and VPCs in them, from where this DNS zone will be accessible:

![](https://cdn-images-1.medium.com/max/831/0*IGQ77mxPq8ZzFJp8.png)

Now, when the zone was created, add some records in there:

![](https://cdn-images-1.medium.com/max/1024/0*dJKMZQsHp73rIfV7.png)

For example, let’s add a record that will be pointed to one of our Staging servers — _app1.stage.mobilebackend.bm.local_:

![](https://cdn-images-1.medium.com/max/1024/0*hU6lL7pUiyqzwYk5.png)

And check if it’s available for another Staging server, located in this VPC:

```
admin@bttrm-stage-console:~$ dig app1.stage.mobilebackend.bm.local +short
10.0.6.68
```

Or by using the [`dnstracer`](https://linux.die.net/man/8/dnstracer) utility:

```
admin@bttrm-stage-console:~$ dnstracer app1.stage.mobilebackend.bm.localTracing to app1.stage.mobilebackend.bm.local[a] via 10.0.6.2, maximum of 3 retries
10.0.6.2 (10.0.6.2) Got answer
```

And we got our response from the 10.0.6.2 — the VPC DNS server, as expected.

Now, try to reach the zone from the office:

```
15:06:02 [setevoy@setevoy-arch-work ~] $ dig app1.stage.mobilebackend.bm.local
; <<>> DiG 9.16.18 <<>> app1.stage.mobilebackend.bm.local
;; global options: +cmd
;; Got answer:
;; WARNING: .local is reserved for Multicast DNS
;; You are currently testing what happens when an mDNS query is leaked to DNS
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 27027
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;app1.stage.mobilebackend.bm.local. IN A
```

And the world is knowing nothing about this DNS zone.

by the way, it’s possible to have the same DNS zone created as Public and private, so-called “split-view DNS”. See [How can I use Route 53 to access an internal version of my website using the same domain name as my public website?](https://aws.amazon.com/ru/premiumsupport/knowledge-center/internal-version-website/) и [Split-view DNS](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zone-private-considerations.html#hosted-zone-private-considerations-split-view-dns).

Done.

_Originally published at_ [_RTFM: Linux, DevOps, and system administration_](https://rtfm.co.ua/en/aws-route53-private-hosted-zones-hiding-domains-from-the-internet/)_._

* * *