DNS troubleshooting – a common challenge solved

Trouble shooting DNS-related issues is a common challenge for web developers who may just have been exposed to challenges with code and databases before. If you set up domains on a dedicated server or a VPS for the first time and facing challenges the following will help.

1) Name servers are set for a domain at the domain name registrar. To see which name servers are set for a domain check www.betterwhois.com (or any other whois service). For example the domain www.domain.info may return the Rackspace name servers dns1 and dns2.stabletransit.com.

2) At the name server proper DNS entries must be set up. An “A entry”, which is usually set up for a hostname, will have fields such as name and IP. An example is subdomain.domain.info as name and 174.143.155.XX as IP. The IP is the server IP. You can trouble shoot this using: http://www.zoneedit.com/lookup.html (if you run linux you can also use the nslookup command).

Name server entries are set up at the name server. In the case of certain web hosting companies such as www.iweb.ca the name server is hosted on the same server as the web server so whenever an account is created in WHM the DNS entries are automatically set up.

In the case of Rackspace the DNS is hosted separately so we need to manually set up a DNS entry in their name server. To avoid having to set up many entries for each subdomain such as abc.domain.info, def.lbclients.info and so on, a wildcard entry can be set up for domain.info. Then any subdomain will point to the IP of choice (your VPS for example).

To reiterate, when you type in subdomain.domain.info your machine will first find the name servers for domain.info, then look up the hostname at that name server, retrieve the server IP, and now to the final step: how will the server know which directory on the server to point the user to?

3) In case of a Linux web server, the httpd.conf file (located in /etc/httpd/conf) tells the web server where on the server that the website can be found. This file will contain a number of “virtual hosts”. It’s called virtual because many hosts can be assigned to the same IP (long time back this was not possible in web server software, but each hostname needed a separate IP). Each virtual host directive will tell the web server where to load files from for a particular host name (ServerName or alias).

<VirtualHost 174.143.155.XX:80>
ServerName domain.info
ServerAlias subdomain1.domain.info www. subdomain1.domain.info
ServerAlias www.domain.info
DocumentRoot /home/domain.com/public_html
</VirtualHost>

These virtual host directives are created automatically when creating an account in WHM, adding a parked or add-on domain. You can trouble shoot this by viewing the httpd.conf file through SSH (pico /etc/httpd/httpd.conf) and looking up the server name or alias.

Conclusion: If the files you put into a folder does not show up when accessing a domain name its very likely there’s a problem in any of the above three steps. In such a case just use the trouble shoot options described above.