Differences between the A and CNAME records

To totally unlock this section you need to Log-in


Record A

The A in A record stands for Address. Simply put, an A record is used to find the address of a computer connected to the internet from a name. Whenever you visit a web site, send an email, connect to Twitter or Facebook or do almost anything on the Internet, the address you enter is a series of words connected with dots.

You can actually do quite a bit more with A records, including using multiple A records for the same domain in order to provide redundancy. Additionally multiple names could point to the same address, in which case each would have its own A record pointing to the same IP address.

The bottom line: A records are used to map a name to a computer’s address on the Internet, and are one of the primary records used in DNS servers.

Record CNAME

These are usually referred to as alias records since they usually map an alias to its canonical name. The name server does handle these queries differently from an A record. When a name server looks up a name and finds a CNAME record, it replaces the name with the canonical name and looks up the new name.

This allows you to point multiple systems to one IP without specifically assigning an A record to each host name. If your IP was ever to change you would only have to change one A record.

The canonical name that a CNAME record points to can be anywhere in the DNS, whether local or on a remote server in a different DNS zone.

For example, if there is a DNS zone as follows:

bar.example.com.     CNAME     foo.example.com.

foo.example.com.     A

When an A record lookup for bar.example.com is done, the resolver will see a CNAME record and restart the checking at foo.example.com and will then return

A, CNAME records are possible solutions to point a host name (name here after) to your site.

However, they have some small differences that affect how the client will reach your site.

Understanding the differences

Here’s the main differences:

The A record maps a name to one or more IP addresses, when the IP are known and stable.

The CNAME record maps a name to another name. It should only be used when there are no other records on that name.

Some important rules to keep in mind:

The A, CNAME records causes a name to resolve to an IP. The A name must resolve to an IP, the CNAME record must point to a name.

Which one to use

Understanding the difference between the A name and the CNAME records will help you to decide.

The general rule is:

  • use an A record if you manage what IP addresses are assigned to a particular machine or if the IP are fixed (this is the most common case).
  • use a CNAME record if you want to alias a name to another name, and you don’t need (such as other records (such as MX records for emails) for the same name.