When we browse the internet, a lot is happening in the background to deliver web pages and services. As a foundation, we have a domain name system (DNS) that help us convert uniform resource locator (URL) links like www.fasthosts.co.uk into IP addresses. In our case, Fasthosts has an IP address of 184.108.40.206. The DNS server will remember the IP address for us, simplifying web browsing.
Delving deeper into DNS, we have DNS records. This is where a URL is saved with a corresponding IP address, which we then use to connect to the website in question. There are numerous DNS record types, including A, CNAME, ALIAS, and URL records. We will be covering CNAME and ALIAS records in detail throughout this guide.
CNAME stands for canonical name record and is used to map one hostname to another hostname. As an example, using a CNAME record, a user would type in www.fasthosts.co.uk, with the DNS service interpreting that URL as fasthosts.co.uk instead.
In this example, fasthosts.co.uk is the A record. This is the most basic type of DNS record and points a domain name to a specific IP address.
NOTE – A subdomain is a prefix attached to a domain name. For example, help.fasthosts.co.uk is a subdomain, and fasthosts.co.uk is the domain. Subdomains are, therefore, used to divide up different sections of your website for easier browsing and categorisation.
A CNAME record can never point to an IP address. It can only point to another domain name. You also cannot have two records which reference the same domain name. As an example, you cannot have a CNAME record and a TXT record that both point to www.fasthosts.co.uk.
While CNAME records are useful for redirecting web traffic, they also incur a performance penalty in the form of additional DNS lookup steps. This penalty is exacerbated when pointing one CNAME record to another CNAME record, meaning you should always try to avoid this.
A CNAME record will be formatted with two customisable elements on most DNS management services. These are the Name and the TTL.
When you specify a Name, the DNS service should automatically append the domain name. For example, you set the Name as www. , then the DNS service will automatically append the domain name fasthosts.co.uk, or our A record.
The TTL stands for time to live. This is the amount of time that a cached CNAME record will be considered accurate. After this time elapses, the CNAME record will be deemed out of date, and a refresh from the authoritative DNS server will take place.
The benefits of CNAME records
So, why would we use a CNAME record?
As CNAME records point to an A record, this is beneficial when changing an IP address. If you change the IP address associated with an A record, you do not need to take the additional step of changing the CNAME IP address association, as it queries the A record for that information.
For example, we could have mail, www, and ftp subdomains for our website stored as CNAME records. This means that, if the A record IP address for fasthosts.co.uk were to change, these changes would also apply to mail.fasthosts.co.uk, www.fasthosts.co.uk, and ftp.fasthosts.co.uk. The use of CNAME records, therefore, also benefits the user experience by masking configuration changes for users.
Depending on the size of your website, and the quantity of traffic, you may only need one hosting server. Rather than having individual servers that deal with ftp and mail, a single hosting server can deliver all content for these subdomains when you use CNAME records.
ALIAS records are very similar to CNAME records. The main difference is that a single CNAME record can only reference a single domain name, whereas multiple ALIAS records can reference a single domain name at once.
In addition, ALIAS records only redirect A records and AAAA records, meaning they do not conflict with other record types like TXT records and URL records. At resolution time, this means that ALIAS records can automatically resolve to one or more A records.
The ALIAS record was created to overcome these problems with CNAME records. An ALIAS record is classed as a custom virtual record and provides CNAME-like behaviour without the limitations of CNAME record types on apex domains (root domains).
Uses and benefits with ALIAS records
One way that you can use ALIAS records is when diverting from a root domain to another location. This cannot be done with CNAME records.
An example of this could be that you want to redirect users that visit example.com to tech.demo.com. You would set an ALIAS record that points visitors from example.com to tech.demo.com, creating a non-HTTP redirect for that domain name.
If you want to redirect users that type an incorrect URL (e.g. heelp.fasthosts.co.uk) to your website, you can do this also with ALIAS records. You would specify the hostname as *, with the asterisk covering any hostnames that aren’t specified in your DNS management service.
If you currently have a domain name registered with Fasthosts or use Fasthosts nameservers for DNS queries, you can follow this guide to set up an ALIAS record on our service.
You will typically find ALIAS records being used on cloud hosting platforms like Fasthosts, to divide up servers existing between subnets in our data centre. This also applies to services that provide IP address pools, like Github with their user-specific Git repositories (github.com/user1, github.com/user2/project1).
Fasthosts for Web Hosting and DNS
Web hosting and DNS configuration can be tedious, but Fasthosts offers the award-winning Fasthosts Control Panel to streamline the process. This unified management dashboard allows you to manage all of the services you currently use with Fasthosts. Our Dedicated and Virtual Private Servers (VPS) use Fasthosts nameservers, meaning DNS queries never leave our data centres. This greatly improves performance when hosting via Fasthosts, and you can also benefit from our 50% off sale for the first three months of your plan (limited time offer).
Give your business services the platform they deserve. Get in touch with our sales team on 0808 1686 777, or via email at email@example.com to find out more!