How to create a custom DNS server in your AWS VPC?

How to create a custom DNS server in your AWS VPC?

September 14, 2020 / Eternal Team

When you create a custom VPC, your VPC is automatically configured to the AWS provided DNS server, and this is used to resolve public DNS host-names and it’s used for host-name resolution. It is also used by the instances within your custom VPC which are communicating over the internet. And we already know that AWS consumes five IP addresses in CIDR blocks.

For example If you create a VPC with CIDR block 10.0.0.0/24, it supports 256 IP addresses. You can break this CIDR block into two subnets, each supporting 128 IP addresses. One subnet uses CIDR block 10.0.0.0/25 (for addresses 10.0.0.0 – 10.0.0.127) and the other uses CIDR block 10.0.0.128/25 (for addresses 10.0.0.128 – 10.0.0.255).

The first four IP addresses and the last IP address in each subnet CIDR block are not available for you to use, and cannot be assigned to an instance. Now as per the documentation, in a subnet with CIDR block 10.0.0.0/24, the following five IP addresses are reserved.

  • 10.0.0.0: Network address.
  • 10.0.0.1: Reserved by AWS for the VPC router.
  • 10.0.0.2: Reserved by AWS. The IP address of the DNS server is the base of the VPC network range plus two. For VPCs with multiple CIDR blocks, the IP address of the DNS server is located in the primary CIDR. We also reserve the base of each subnet range plus two for all CIDR blocks in the VPC. For more information, see Amazon DNS server.
  • 10.0.0.3: Reserved by AWS for future use.
  • 10.0.0.255: Network broadcast address. We do not support broadcast in a VPC, therefore we reserve this address.

But if you don’t want to use the AWS provided DNS server, and instead, you want to use your own custom DNS server. How can you achieve this?

Step 1

Login to your AWS console and go to the VPC section.

Step 2

After creating your Custom VPC, Click on “action” and click on “Edit DNS resolution”.

how-to-create-a-custom-dns-server-in-your-aws-vpc

how-to-create-a-custom-dns-server-in-your-aws-vpc

Just uncheck the “enable” option and save it.

Step 3

Go to the “DHCP option sets” and create a new DHCP options set.

how-to-create-a-custom-dns-server-in-your-aws-vpc

Then at DHCP options, this is where you can add your domain name servers. You can enter up to four DNS server IP addresses, so you can add your own DNS servers right there.

how-to-create-a-custom-dns-server-in-your-aws-vpc

And click on “DHCP options set”

Finally, your custom DNS server is created with your domain name.

After creating your DNS server, go to the VPC section and attach the DNS server to your custom VPC.

AWS-Consulting-Partner

Talk to AWS Certified Consultant

Want to start a project?

It’s simple.

Contact us