DNS mapping for AWS hosted blogs

AWS, Blogging, Technology / Thursday, December 28th, 2017

So you have set up your blog on AWS as directed by the previous article. At this point your blog is accessible by typing a sequence of numbers (IPv4 address provided by AWS) in your browser. That is fine if you are the only one using the blog, but when you are ready to announce it to the world and want people to easily get to your blog, then you have to provide a name rather than an odd sequence of numbers. Imagine if we the only way to get to websites would be by remembering the numbers – there wouldn’t be many people surfing the web.

This issue is exactly the reason why in the early 1980s a bunch of very smart people got together and came up with what is now known as the Domain Name System (DNS). During the early days of the Internet (Arpanet era), there was no DNS system. The number of connected computers were few enough that each network maintained a simple text file called Hosts.txt which listed a mapping of IPv4 addresses to names. So when a computer needed to send data across the network it referenced this file to find out the IP address associated with the name and sent the data across to that address.

As these networks grew bigger and more interconnected, the individually maintained text files was no longer sufficient to serve the needs of the applications – especially the growth of email on Arpanet. DNS system addresses all these issues with an elegant design. DNS today is a very complex distributed system and has many additional enhancements from the earliest version. Here I’ll only touch on the basics needed to conceptually understand what needs to be done to enable access to your blog.

A Registrar is a central component of the DNS system. The Registrar maintains the information about your domain name and which NameServers the domain is associated with.

A NameServer maintains the indivdual DNS records for the domains. They usually come in multiples, at least a primary and secondary pair for reliability. The indiviual DNS records maintain the mapping of your name to IP address in what are known as Zone files. There are several record types defined, the ones that are of interest to us are the A record and the CNAME record. These are the main records that you will need to add.

The company from which you bought the Domain Name is typically the one that provides the Registrar functionality and maintains the NameServers.

Login to the AWS dashboard, copy the public IP address and the public DNS from the EC2 instance. Now login to your DNS provider (GoDaddy, NameCheap etc) and find the page where you can modify the DNS records. As an example for NameCheap the below is the screen where modifications are to be made. You need to modify the ‘A record‘ and ‘CNAME record

A record –  maps a hostname to an IP address (IPV4 address specifically). Add the public IP address copied earlier to the A record.

Update A record


CNAME record – called the canonical record name maps a name to another name and resolves to the IP address. Set the CNAME record to the public DNS copied from AWS.

Update CNAME record


You are done adding DNS records. It will typically take some time for the update to take effect. After some 5-10 minutes type in your blog name in the browser and voila it should open up the blog home page.

Leave a Reply

Your email address will not be published. Required fields are marked *