DNS records explained: A, AAAA, NS, MX and CNAME (2024)

DNS records explained: A, AAAA, NS, MX and CNAME (1)

The domain name system and its many acronyms and letters made clear.

For your web browser to display a website it needs to translate the domain name into something called an IP address. This is all done by DNS (domain name system).

In my last blog post I explained how DNS and domain names work. This is the second part, taking a look at the main DNS record types and what they’re used for.

DNS record types:

  • nameserver (NS)
  • glue records
  • A record
  • AAAA record
  • CNAME
  • MX
  • TXT record

For a full list check the Wikipedia DNS record type list.

Nameserver (NS)

Without nameserver (NS) records a website would not work.

The NS record is stored by the Top Level Domain (TLD) server.

There are over 1,000 TLD servers. There is one for .com domains, another for .gov domains, and so on.

You can update your NS record with the company you bought your domain from (also known as your domain registrar). The domain registrar will then update the TLD server.

NS records look something like this.

  • andy.ns.cloudflare.com
  • dave.ns.cloudflare.com

You normally have at least 2 NS records.

They look like a website URL, but Instead of linking to a website, they link to the domain names authoritative nameservers.

The authoritative nameservers store most of your DNS records with a few exceptions such as NS and glue records.

When you buy a domain name it normally has some default NS records managed by the domain registrar.

For example my websites registrar is hover.com. Their default NS records are:

  • ns1.hover.com
  • ns2.hover.com

You can use the domain registrars authoritative nameservers to add other DNS records such as a CNAME or A record.

However, as soon as you change NS records to point somewhere else any DNS records added with the domain registrar will be ignored.

Hopefully your domain registrar will say your DNS settings aren’t in use – 123-reg do.

DNS records explained: A, AAAA, NS, MX and CNAME (2)

Unfortunately some don’t which can be confusing – it confused me.

Basically the NS record is king. They have ultimate control of where a domain should go.

Glue record

Glue records are only needed if you are running your own nameservers – most people don’t.

A glue record is the IP address of the authoritative nameserver. You create the glue record with your domain registrar.

A record, also known as IPv4 address record

The A record is used to point the domain name at one or multiple IP addresses.

An IP address looks something like this 74.125.224.72

The IP address is the place where your website is hosted.

If you use a managed hosting provider, such as wordpress.com, and you are using the hosting providers nameservers you won’t need to create an A record.

If or when you create an A record there are three fields to fill in:

  • name
  • destination
  • TTL

Name

I’ve seen the ‘name’ field called hostname, alias, prefix and DNS entry. Whatever it may be called there are three variations of what could go in the field:

  • @
  • *
  • Subdomain such as www

An @ in the ‘name’ field means the A record will only affect the second level domain (SLD) – also known as the root domain.

DNS records explained: A, AAAA, NS, MX and CNAME (3)

An * (asterisk) in the name field is a wildcard, and represents any subdomain / prefix. For example, creating the record *. pbrumby.com would affect all subdomains such as:

  • ftp.pbrumby.com
  • www.pbrumby.com
  • preprod.www.pbrumby.com

The last option is to add the specific subdomain / prefix. For example www or preprod.www

Destination

Just like the name field I’ve seen this called ‘IP’, ‘content’ and ‘target name’. This is where you add your website server IP address.

Time-to-live (TTL)

All DNS records have a TTL (time-to-live) entry.

The TTL indicates how long until your computer, or resolver has before it should recheck with the authoritative nameserver.

For example if you set the TTL to be 5 minutes it would take 5 minutes for all the computers in the world to use your new setting.

You can check the TTL on any DNS record by using a DNS checker such as Google’s dig.

The format you get back looks something like this.

google.com. 300 IN A 173.194.222.101

The first number ‘300’ is the TTL. It is measured in seconds. So 300 seconds equals 5 minutes.

AAAA record, also known as IPv6 address record

AAAA record does the same thing as the A record but the IP address is a longer.

Internet Protocol version 4 (IPv4) defines an IP address as a 32-bit number. However, because of the growth of the internet and the depletion of available IPv4 addresses, a new version of IP (IPv6), using 128 bits for the IP address was created.

CNAME record

If you are already using an A or AAAA record for a subdomain you wouldn’t use a CNAME.

The Canonical Name record (CNAME) tells anyone visiting that subdomain to use the same DNS records as another domain / subdomain.

This can be convenient when running multiple services from a single IP address.

CNAME records must always point to another domain / subdomain, never directly to an IP address.

CNAME records also only work for subdomains.

For example you couldn’t use a CNAME for pbrumby.com.

But you could for a subdomain like www.pbrumby.com.

Using a CNAME record can cause a very minor delay of a few milliseconds as there is an additional request sent to the DNS servers.

MX record

Mail Exchanger (MX) records are used to create email addresses from that domain.

The MX record is used to tell the world which mail servers accept incoming mail for your domain and where emails sent to your domain should be routed to.

MX records consist of four parts:

  • name
  • Priority (number)
  • destination
  • TTL

The name, destination and TTL fields do the same thing as the A record fields. The only difference is the priority number which is used to indicate which server should be attempted to be used first. The lower the number the higher the priority.

In the example below for google.com the first number, 600, is the TTL. The second number (10, 20 or 30) is the priority. The first record (alt1.aspmx.l.google.com.) has the highest priority as it has the lowest number.

google.com. 600 IN MX 10 alt1.aspmx.l.google.com.google.com. 600 IN MX 20 alt2.aspmx.l.google.com.google.com. 600 IN MX 30 alt3.aspmx.l.google.com.

TXT record

A TXT record (short for text record) is used to add arbitrary text.

It’s often used to include verification of domain ownership.

This is by no means a complete list. It does however cover the most common uses.

Tags
  • Domains
  • Tutorial
  • DNS

DNS records explained: A, AAAA, NS, MX and CNAME (4)

About the author

Hi, I'm Peter Brumby, a Digital Product Manager. This is my blog on web development and technology. It's my brain dump and personal library, where I share and save useful info. Hope it helps you too.

  1. DNS records explained: A, AAAA, NS, MX and CNAME (5) flo says:

    21 September, 2020 at 9:00 am

    good explanation thank you very much

    Reply

  2. DNS records explained: A, AAAA, NS, MX and CNAME (6) Said says:

    15 January, 2021 at 9:45 pm

    Thank u.

    Reply

  3. DNS records explained: A, AAAA, NS, MX and CNAME (7) Sami says:

    4 May, 2021 at 10:17 am

    Hi,

    Thanks for the good explanation.

    Is there a way to set priority for A and AAAA ? i.e. : I’d like to force all my clients to connect to my site usin ipv6, and if it fails then use ipv4. Is it possible ?

    Reply

    • DNS records explained: A, AAAA, NS, MX and CNAME (8) Peter Brumby says:

      5 May, 2021 at 8:21 pm

      Hi Sami. A records (ipv4) and AAAA records (ipv6) can live alongside each other. The clients resolver library will request A or AAAA records as appropriate for the type of IP addressing in use by the operating system.

  4. DNS records explained: A, AAAA, NS, MX and CNAME (9) Charybdis.ch says:

    8 May, 2021 at 6:54 pm

    So must I put in; *.my-domaine.com or only *my-domaine.com
    for the first Field?
    Kind Regards Charybdis

    Reply

  5. DNS records explained: A, AAAA, NS, MX and CNAME (10) Dasun says:

    10 November, 2021 at 7:04 am

    Nice explaination

    Reply

  6. DNS records explained: A, AAAA, NS, MX and CNAME (11) Marc says:

    13 August, 2022 at 12:02 pm

    Thanks for great explanation!!

    I have one question.

    Can You point MX of a domain to one email like to ProtonMail account and second to Gmail?

    Two possibilities:
    (I prefer these one if possible)
    [emailprotected] – at Proton
    [emailprotected] – Gmail

    or

    [emailprotected] – Proton
    [emailprotected] – Gmail

    I’m new, discovering.

    Reply

  7. DNS records explained: A, AAAA, NS, MX and CNAME (12) Hector A. says:

    22 August, 2023 at 3:49 pm

    You could not have explained it any simpler. Great job!

    Reply

  8. DNS records explained: A, AAAA, NS, MX and CNAME (13) Justin Warren says:

    10 November, 2024 at 10:36 pm

    I was trying to access a site for a developer based in Russia on Google play, but when taken to their developer’s website it comes up with NS! on their page. Is that a sign that their server is down or their website has been blocked from accessing it?

    Reply

    • DNS records explained: A, AAAA, NS, MX and CNAME (14) Peter Brumby says:

      12 November, 2024 at 7:10 pm

      Yes, you’re probably right. The website might be blocked, either by your internet provider or the website’s hosting service, or it could be down due to technical issues. Using a VPN could work around the problem, but it might be best to avoid it.

  9. DNS records explained: A, AAAA, NS, MX and CNAME (15) Rodrigues says:

    14 November, 2024 at 11:13 am

    Simple and crisp explanation

    Reply

Leave a comment

DNS records explained: A, AAAA, NS, MX and CNAME (2024)
Top Articles
Latest Posts
Recommended Articles
Article information

Author: Chrissy Homenick

Last Updated:

Views: 6205

Rating: 4.3 / 5 (54 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Chrissy Homenick

Birthday: 2001-10-22

Address: 611 Kuhn Oval, Feltonbury, NY 02783-3818

Phone: +96619177651654

Job: Mining Representative

Hobby: amateur radio, Sculling, Knife making, Gardening, Watching movies, Gunsmithing, Video gaming

Introduction: My name is Chrissy Homenick, I am a tender, funny, determined, tender, glorious, fancy, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.