AWS DNS Records - A, CNAME, ALIAS, & MX

aws
A summary of differences between AWS Route53 DNS Records
Published

February 22, 2022

About

This post summarizes the differences between AWS Route53 DNS records namely A record, CNAME, ALIAS, and MX. Knowledge about these differences is commonly checked in AWS certifications.

Credits

This post takes help from a few other really good articles. Please refer to them if you need more details on this subject

First, some definitions

Domain Name

  • Domain + TLD = Domain Name
  • When you buy a ‘domain’ from a a registrar or reseller, you buy the rights to a specific domain name (example.com), and any subdomains you want to create (my-site.example.com, mail.example.com, etc).
  • The domain name (example.com) is also called the apex, root or naked domain name.
  • Examples of protocol are http, ftp, TCP, UDP, FTP, SMTP etc.
  • Examples of top level domains are .org, .net, .com, .ai etc.

A Record

A record (or an address record) always points to an IP address. This IP address should be static like AWS Elastic IP Addresses (EIP)

Example use cases

  • You can point your root domain name example.com to an Elastic IP Address 192.0.2.23

  • We can also map EC2 instances IPv4 Public IP Address to an A record. But this is not recommended as EC2 instances public IP addresses change when you stop/start your server. We should always use Elastic IP addresses instead.

AAAA Record

AAAA record is similar to A record but for IPv6 addresses.

MX Record

MX records (Mail Exchange records) are used for setting up email servers.

CNAME Record

CNAME records must always point to another domain name, never directly to an IP address. Since it does not point to an IP address, it is commonly used along with an A record.

One can, for example, point ftp.example.com and/or www.example.com to the DNS entry example.com, which in turn has an A record that points to the IP address. Then, if the IP address ever changes, one only has to record the change in one place within the network: in the DNS A record for example.com.

Example use cases

NAME TYPE VALUE
www.example.com CNAME example.com
example.com A 192.0.2.23
  • An A record for example.com (root domain) points to server IP address

  • A CNAME record points www.example.com to example.com

Now if the IP address of your server has changed you will have to update it only at one place A record. www.example.com and example.com will automatically inherit the changes.

IMPORTANT

  • CNAME entry for the root domain is not allowed.

NAME TYPE VALUE
example.com CNAME app.example.com
app.example.com A 192.0.2.23

Alias Record

It is AWS Route 53 specific and only works with it. Alias works similar to CNAME but they are created by AWS to solve their specific problems discussed next.

AWS S3 buckets, Elastic Load Balancers, Elastic Beanstalk, and CloudFront offer you DNS names only and no IP addresses. e.g. when you create an S3 bucket you will get its DNS name bucket_name.s3.amazonaws.com. Now if you want to map your root domain example.com to S3 bucket DNS then we don’t have any options left as

  • A record points to IP addresses only

  • CNAME cannot be used for root domain name

For this AWS came up with an Alias record in Route 53. With Alias record, you can point your domain root to another DNS name entry.

NAME TYPE VALUE
www.example.com CNAME example.com
example.com Alias bucket_name.s3.amazonaws.com