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.

Add domain to EditDNS

Click on “Add domain”. After adding your domain, you’ll see that your domain name is written in red. Don’t worry, this is perfectly normal. It’ll go back to normal after you change your name servers to that of EditDNS’s and the changes propagate. Now, click on the “Edit” icon beside “mydomain.com”. You’ll come to a page that looks like this :

EditDNS name servers

Take a note of the name servers (highlighted in red).

List of nameservers (US only) :

  • ns1.us.editdns.net
  • ns2.us.editdns.net
  • ns3.us.editdns.net

List of nameservers (EU only) :

  • ns1.eu.editdns.net
  • ns2.eu.editdns.net

List of nameservers (EU+US) :

  • ns1.us.editdns.net
  • ns2.us.editdns.net
  • ns3.us.editdns.net
  • ns1.eu.editdns.net
  • ns2.eu.editdns.net

To change between US/EU/EU+US name servers, click on the corresponding link after “Change NS: ” in the “Additional Services” section. I’d recommend changing to EU+US name servers because it will be more fault-tolerant and your domain will resolve faster across the globe.

Now you need to go to your DNS management console of your domain registrar/host, delete all name servers and add the EditDNS’s name servers. Now, let’s go back to EditDNS’s DNS management. To add a record, type in the record name, select the type of record (A, AAAA, CNAME, MX, SRV, TXT, PTR) and type in the IP/Hostname. Don’t change the AUX and TTL values unless you need to. A TTL value of 86400 seconds is enough for your domain. To edit a DNS record, double click on it, make the necessary changes and click on “Save”.

Scenario 3: Set up a subdomain or a sub-subdomain

To set up a sub domain, simply create an A record for the subdomain and point it to the IP of server on which it is to be hosted.

For example, if you want to create a subdomain called vanilla.mydomain.com to be hosted on IP 1.2.3.4, create an A record like this :

flavour.mydomain.com A 1.2.3.4

If you want www.vanilla.mydomain.com to work, simply create another A record like this :

www.flavour.mydomain.com A 1.2.3.4

To set up a sub-domain, please see this post.

That pretty much ends this guide. If you have any DNS problems, post a comment below and I’ll help diagnose it.

4 Comments

  1. [...] been getting quite a few hits from Google to the DNS Guide post from people searching for how to set up a sub sub domain. One of the most popular example of a [...]

  2. sandrar says:

    Hi! I was surfing and found your blog post… nice! I love your blog. :) Cheers! Sandra. R.