A guide to DNS


DNS or Domain Name System, is a core Internet protocol/mechanism which resolves text URLs(FQDNs) into IP addresses. It is the protocol which translates hostnames such as “www.google.com” into it’s IP address -“72.14.207.99″. In essence, it acts as the ‘phone book of domain names” and mapping the names(domain names) to their phone numbers (IP addresses). This system also stores other information about a domain, such as it’s mail servers.

The most dreadful situation is when your DNS is set up incorrectly. Most webmasters dread the thought of incorrectly configured DNS, as they can’t figure out where they went wrong. But troubleshooting DNS problems is very easy, considering you know how to use tools like nslookup, dig, bind, etc. Before we go into tutorials, it would be a good idea to look up the various types of DNS records at Wikipedia.

Here we’ll be discussing about various scenarios faced by domain name owners while configuring their DNS.

Scenario 1 : You need to host a sub-domain on another host or on a different server with a different IP

First you need to add your sub-domain, say “flavour.mydomain.com” to the control panel of the other host, so that they can add your domain their name-servers and create the required A records. Next, you need to know from your new host, the IP address of the server on which your sub-domain is going to be hosted. Say it is “1.2.3.4”. Now you need to go to your DNS management console of your domain registrar/host and create A records for that sub-domain pointing to the IP address of the server of the new host. So, your DNS records should look like this :

flavour.mydomain.com   A   1.2.3.4
www.flavour.mydomain.com   A   1.2.3.4

Add the second A record only if you want www.flavour.mydomain.com(a sub-sub-domain) to work. It is always a good idea to add records for “www.flavour.mydomain.com” and then 301 redirect all traffic from “www.flavour.mydomain.com” to “flavour.mydomain.com”.

The above effect can also be achieved by using a CNAME record instead of an A record, but using a CNAME record is not recommended because of theoretical overhead issues. But if you want to do what’s not recommended, add a CNAME record pointing “www.flavour.mydomain.com” to “flavour.mydomain.com”; so that the DNS records looks like this :

flavour.mydomain.com   A   1.2.3.4
www.flavour.mydomain.com   CNAME   flavour.mydomain.com

Give some time for the DNS changes to propagate(Usually around 30 minutes) and start using your sub-domain right away.

Scenario 2: Your registrar or host doesn’t let you manage your DNS

First of all, I’d recommend transferring your domain from the registrar/moving away from host which doesn’t allow you full DNS control. But if you are hard bound to stay with them, there is still hope for you. There are a lot of 3rd party DNS hosts who would host your domain’s DNS for free. Some of the most popular ones are EditDNS and Afraid.org, but there are quite a few other free DNS hosts which are equally good. I’ll be using EditDNS for this guide.

First of all, register with an account with EditDNS. After signing into your account, navigate to your Control Panel and add your domain(say “mydomain.com”) without www. In the “Default IP” box under Optional Settings, enter the IP address of the server which hosts your domain.