Hosting and planning
DNS Records Explained: A, AAAA, CNAME, MX, TXT, NS, TTL
DNS is the directory that turns your domain name into the servers that host your website and receive your email, and each record type answers a different question. Changes spread as cached copies expire, so they appear at different times for different people; you can check the real answer with dig or nslookup.
By CodingMarble · Published · 5 min read

What DNS does and who answers
Computers reach each other by IP address, but people remember names. The Domain Name System connects the two. When someone types your domain, their device asks a recursive resolver, usually run by their internet provider or a public DNS service. If the resolver does not already know the answer, it asks the root servers, then the servers for the top-level domain, then finally your domain's authoritative name servers, which hold the real records.
You edit those records in a DNS zone. The zone usually lives at your registrar, at your hosting company, or at a CDN, depending on which name servers your domain points to. A frequent source of confusion is editing records in one place while the domain actually uses name servers somewhere else. Those edits do nothing, so always confirm where the zone is hosted first.
The record types you will actually use
- A record: maps a name to an IPv4 address. This is how example.com reaches a web server.
- AAAA record: the same, but for an IPv6 address. Only add it if your server really listens on that address.
- CNAME record: makes one name an alias of another name, such as www pointing to your host's address name. The target is a hostname, never an IP address.
- MX record: names the mail servers that accept email for the domain, each with a priority number; lower numbers are tried first.
- TXT record: holds free-form text. It is used for domain verification and for email authentication policies such as SPF, DKIM and DMARC.
- NS record: lists the authoritative name servers for the domain. Changing these hands control of the whole zone to another provider.
Every record also carries a TTL, or time to live, measured in seconds. It tells resolvers how long they may keep the answer before asking again. A long TTL reduces lookups and speeds up repeat visits; a short TTL makes changes take effect sooner but increases query load. Panels often offer an automatic or default value, which is fine for most sites.
How propagation works and why it varies
Nothing is actually pushed across the internet when you change a record. The authoritative server starts giving the new answer immediately. What takes time is that resolvers all over the world are holding the previous answer in their cache, and each one keeps it until its TTL runs out. Different resolvers cached it at different moments, so they expire at different moments. That is why you see the new site while a colleague still sees the old one.
Several factors stretch the process. The old record's TTL controls how long caches may lag, not the new one, so lowering the TTL a day or so before a planned move shortens the overlap. Some resolvers and devices cache longer than they should. Browsers and operating systems keep their own caches too. And name server changes at the registry level can take longer than a record edit inside a zone. There is no single dependable number, so plan migrations so both the old and new servers work during the overlap.
Pointing a domain to hosting and adding www
Your host will give you either an IP address or a hostname to point to. With an IP address, create an A record for the apex (the bare domain, shown as @ in most panels). For www, either create a second A record to the same address or a CNAME from www to the apex name. If the host gives you only a hostname, use a CNAME for www and check the host's instructions for the apex, since some providers offer an alias-style record for it.
Type Name Value TTL
A @ 203.0.113.10 3600
CNAME www example.com. 3600
MX @ 10 mail.example.com. 3600
TXT @ "v=spf1 include:_spf.mailhost.example ~all"The addresses and names above are documentation examples, not real values. After saving, also make sure the web server is configured to answer for both names, and decide which one is canonical so the other redirects to it. If you use HTTPS, the certificate must cover both hostnames.
Email records: MX, SPF, DKIM and DMARC
Email needs its own set of records, and the values come from your mail provider, not from this guide. MX records say where incoming messages go. Three TXT-based records then help receiving servers decide whether your outgoing messages are genuine.
SPF lists the servers allowed to send mail for your domain. A domain should have only one SPF record, so if you use several senders, merge them into one line instead of adding a second. DKIM publishes a public key under a selector name; your mail system signs each outgoing message, and receivers verify the signature using that key. DMARC sits on top: it tells receivers what to do when SPF and DKIM do not line up with the visible From domain, and where to send reports. A cautious start is a monitoring-only policy, moving to stricter policies once reports show that legitimate mail passes.
Without these records, legitimate messages are more likely to be treated as spam, and others can more easily forge your domain. Your email provider's setup page lists the exact records to paste; copy them exactly, since one missing character invalidates a key.
Verifying with dig and nslookup
Do not rely on how a page looks in your browser, since caches mislead. Query DNS directly. dig is common on Linux and macOS; nslookup ships with Windows. Asking a specific resolver, or the authoritative server, shows whether the change exists at the source versus only in a cache.
dig example.com A +short
dig www.example.com CNAME +short
dig example.com MX +short
dig example.com TXT +short
dig example.com NS +short
# Ask a specific public resolver instead of your default one
dig @1.1.1.1 example.com A +short
# Ask the authoritative server named in the NS output
dig @ns1.example-dns.com example.com A +shortnslookup -type=A example.com
nslookup -type=MX example.com
nslookup -type=TXT example.com
nslookup -type=NS example.com 8.8.8.8Practical tip: if the authoritative server already gives the new answer but your resolver does not, nothing is wrong with your records. You are waiting for a cache to expire, so avoid making further edits that only reset the situation.
Common mistakes
A CNAME at the apex is the classic error. The DNS rules say a name with a CNAME cannot hold any other record, but the apex must also carry NS and SOA records, and usually MX and TXT as well. A plain CNAME there either gets rejected by the panel or, worse, breaks email. Use A and AAAA records at the apex, or a provider-specific alias feature if one exists. CNAMEs are fine on subdomains such as www.
Deleting MX records by accident is the next most damaging slip. People remove old records while pointing a domain to a new host, and mail starts bouncing or disappearing. Before changing anything, export or screenshot the entire zone. Also avoid leaving a stale AAAA record that points to an old server, because visitors with IPv6 will be sent there even after the A record is correct. Other mistakes: adding a second SPF record, forgetting the trailing dot in some zone-file formats, pasting a CNAME target that includes http://, and changing name servers without first copying all existing records to the new provider.
Keep reading
- Hosting and planningAdd Your Website to Google Search Console Step by StepCreate a property for your site, prove you own it with a DNS record, HTML file or meta tag, then submit your sitemap and check key pages with the URL Inspection tool. Indexing is not instant or uniform, so use the Pages report to understand each status instead of repeatedly resubmitting.
- Hosting and planningInstall a Free SSL Certificate and Enable HTTPSA free SSL certificate, usually from Let's Encrypt, encrypts traffic between visitors and your server and proves your domain is yours. On shared hosting it is typically a one-click setting, and on a VPS you can issue and renew it with certbot and nginx.
- Hosting and planningWeb Hosting Types Explained: Shared, VPS, Managed, CloudThe right hosting type depends on what your site runs, how much traffic it gets and who will maintain it: shared hosting suits small, simple sites, a VPS suits people who can administer a server, and managed or static options trade control for less work. Before you pay, check the uptime commitment in writing, how backups are restored, which Node and PHP versions are supported, and what support actually covers.
- Hosting and planningWebsite Backup Strategy for Small Business: Backups That RestoreA good website backup strategy copies your files, database and configuration to at least one location away from the server, on a schedule that matches how often your content changes. A backup you have never restored is only a hope, so schedule a regular restore test.
Need this built properly for your business?
CodingMarble is a remote studio in India that builds websites, apps and games on fixed packages with the scope written down before payment. Try the free tools we run, or start a project when you are ready.