Custom Top-Level Domains

A top-level domain, or TLD, is the final section of a domain name: .com, .org, .net, etc.  By customizing our own DNS server, we’ve created TLDs for each of our environments: .dev, .qa, .stg, and .prod.  This allows everyone to navigate countless projects across several environments by simply appending the environment name to the hostname in the URL.

Customized TLDs

An example website in each environment.

To accomplish this, our BIND server named.conf contains entries like:

zone "dev." in {
    type master;
    file "/var/named/zones/wildcard/dev";

That zone file contains a single wildcard CNAME record:

@ IN SOA dev. (
  0  ; serial
  3H ; refresh
  1H ; retry
  1W ; expire
  1H ; minimum

Anything ending in .dev will resolve to this server, where Apache’s virtualhost configurations will select the appropriate site based on server names and aliases.

This process has worked well for the last couple of years.  Everyone knows exactly where to find any project, in any environment, no matter how many thousands of sites we develop and maintain.  Also, our sysadmins can quickly distinguish private and public routing for subnets that have external access (i.e. staging and production).  Adding or removing .prod from the URL can help troubleshoot a variety of networking issues.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s