DNS Explained for Beginners: A, CNAME, MX, and TXT Records
Learn how DNS records connect websites, route email, and verify domain ownership, with simple examples and practical lookup commands.
What is DNS?
The Domain Name System, or DNS, helps computers resolve names such as www.example.com.
When you open a website, your computer typically asks a DNS resolver for an answer. The resolver checks its cache or queries the DNS hierarchy to find information from the domain’s authoritative nameservers.
DNS is only one part of opening a website. After resolving the name, your browser still needs to connect to the server and request the page. A correct DNS answer does not guarantee that the website or its HTTPS certificate is working.
Five common DNS record types
Record | Purpose | Example |
|---|---|---|
A | Maps a name to an IPv4 address |
|
AAAA | Maps a name to an IPv6 address |
|
CNAME | Makes one name an alias of another |
|
MX | Identifies a domain’s incoming mail server | Priority |
TXT | Stores text used by services |
|
These are fictional examples. When configuring your domain, use the exact values supplied by your hosting or email provider.
A and AAAA records: where a name resolves
An A record contains an IPv4 address. An AAAA record contains an IPv6 address. A domain name can have both.
Your hosting provider may ask you to create an A record when connecting a website. Other providers give you a hostname and ask for a CNAME instead.
In many DNS dashboards:
@represents the root domain, such asexample.com.wwwrepresentswww.example.com.
Check the provider’s preview before saving. Some dashboards automatically append your domain to the name you enter.
CNAME records: aliases, not browser redirects
A CNAME makes one hostname an alias of another hostname.
For example:
Name: www
Type: CNAME
Target: example.comThe target is a hostname. It should not contain https:// or a page path such as /blog.html.
A CNAME does not make the address in your browser change. Redirecting visitors from:
https://www.example.com/blog.htmlto:
https://example.com/blog.htmlrequires an HTTP redirect configured at your hosting service or an edge service such as Cloudflare.
A standard CNAME also cannot coexist with other record types at the same name. Some providers support special features for root domains, such as CNAME flattening. Follow your provider’s instructions for those cases.
MX records: where incoming email goes
An MX record identifies a server that receives email for a domain.
It includes:
A mail server hostname.
A priority number.
Lower priority numbers are preferred. Several MX records can provide alternative delivery destinations.
For example:
Priority: 10
Mail server: mail.example.comThe target is a hostname, not an email address.
Moving your website does not necessarily mean moving your email. If your email provider remains the same, preserve its MX records unless the provider instructs you otherwise.
TXT records: verification and email authentication
TXT records store text that services can read.
Common uses include:
Proving domain ownership.
Publishing SPF email policies.
Publishing DKIM public keys.
Publishing DMARC policies.
A domain verification record might look like this:
google-site-verification=EXAMPLE_ONLYWhen a service supplies a verification value, copy it completely. Do not replace an unrelated email record with it.
TXT records are publicly queryable. They are not a place to store passwords, private API keys, or account recovery codes.
Practise reading DNS records
You do not need to edit a domain to learn about DNS.
On Windows, open PowerShell or Command Prompt and run:
nslookup -type=A example.com
nslookup -type=MX example.com
nslookup -type=TXT example.comOn Linux or macOS, if dig is installed, run:
dig example.com A +short
dig example.com MX +short
dig example.com TXT +shortThese commands query DNS. They do not change it.
The answers can change over time, and some record types may return no answer. MX results usually contain a priority number followed by a hostname. TXT results may appear inside quotation marks.
An empty answer does not automatically mean the website is offline. It may simply mean that the name has no record of the requested type.
What does TTL mean?
TTL stands for time to live. It tells a cache how long it may retain a DNS answer.
For example:
TTL: 3600 secondsThat represents one hour.
Changing a record at the authoritative provider does not immediately remove the previous answer from every resolver’s cache.
If a change is not visible yet:
Confirm that the record name is correct.
Check the value for missing characters.
Confirm that you edited the domain’s authoritative DNS provider.
Allow existing cached answers to expire.
Repeatedly changing settings can make the problem harder to diagnose.
Try it yourself
Choose a domain you own and look up its A, MX, and TXT records.
Write down:
Which records relate to the website.
Which records relate to email.
Which records appear to verify ownership for a service.
Do not change anything for this exercise.
Before making a real DNS change, record the previous settings and why you are changing them. Understanding which service depends on a record matters more than memorising its name.