◐ ai-teacher

🚀 Deployment & Ops · Chapter 1

DNS end to end — A records, CNAME, TTL

Your DNS change is correct and the site still shows the old page. Nothing is broken — something is remembering.

Study this lesson free in the app →

The basics

DNS (the Domain Name System) turns a name you can remember, like ai-teacher.in, into the IP address a computer actually connects to, like 76.76.21.21.

The problem it solves: machines move. Servers get replaced, hosts change, a laptop's address changes every time it rejoins wifi. If links pointed at raw numbers, every move would break every link. DNS gives you a name that stays put while the number behind it changes.

The mental model: a phone book with a memory. Your device asks a resolver "what's the number for this name?" The resolver asks the domain's authoritative nameservers, hands back the answer — and remembers it for as many seconds as the record's TTL allows. That memory is why a correct change can look wrong for a while: nothing is being pushed anywhere; caches are simply expiring at different times.

Words you must know 5

A record
name → IPv4 address
CNAME
name → another name, which is then looked up too
TTL
seconds a resolver may cache an answer
Resolver
the server that answers and caches DNS lookups for you (your ISP, 8.8.8.8, 1.1.1.1)
Nameserver (NS)
the server that holds the real records for a domain

Explained

This app was reachable at 192.168.0.180. Then 192.168.0.134. Then 192.168.0.183.

Every time the laptop reconnected to wifi, the address moved and every saved link died. That is the problem DNS solves: a name that does not move, pointing at a number that does.

DNS is a phone book.

You type ai-teacher.in. Your computer has no idea what that means — it can only talk to numbers. So it asks a resolver, "what is the number for this name?" The resolver asks the domain's nameservers, gets an answer, hands it back, and remembers it for a while.

That last part — remembering — is where almost all the confusion lives.

The record types you will actually use

A — a name → an IPv4 address. ai-teacher.in → 76.76.21.21. The bottom of the chain; it points at a machine.

AAAA — the same thing for IPv6.

CNAME — a name → another name. www.ai-teacher.in → cname.vercel-dns.com. The resolver then has to look that up too. Useful when the target's IP might change and you want to let someone else manage it.

NS — who is authoritative for this domain. Change these and you hand the whole domain to a different provider.

MX — where email goes. Untouched by anything you do to your website — which is why moving nameservers can silently break email if you forget to bring the MX records with you.

TXT — arbitrary text, used for domain verification and email auth (SPF, DKIM).

ai-teacher.in is registered at GoDaddy and still uses GoDaddy nameservers, so the records live there:

| Type | Name | Value | | --- | --- | --- | | A | @ | 76.76.21.21 | | CNAME | www | cname.vercel-dns.com |

@ means the domain itself — the apex or root. Note that the apex gets an A record and www gets a CNAME: that split is not arbitrary, and the next lens explains why.

Why the apex cannot be a CNAME

The DNS spec says a CNAME cannot coexist with any other record on the same name.

Your apex almost always has other records — NS, SOA, usually MX for email. So a CNAME at the apex is illegal, and that is why hosts hand you a raw IP address like 76.76.21.21 for the root and a CNAME for www.

Some providers offer ALIAS or ANAME records, which fake a CNAME at the apex by resolving it server-side. They work, they are not standard, and they only exist at providers who built them.

13 August, 06:10. The A record for ai-teacher.in was changed to 76.76.21.21.

A minute later, curl https://ai-teacher.in returned a GoDaddy parking page.

The instinct is to assume the change failed and go change it again. That instinct is wrong, and re-editing records that were already correct is how people turn a five-minute wait into a two-hour outage.

The check that settles it is asking a resolver that has no reason to have cached anything:

dig +short ai-teacher.in A            # 76.223.105.230  ← my laptop, stale
dig +short ai-teacher.in A @8.8.8.8   # 76.76.21.21     ← Google, correct
dig +short ai-teacher.in A @1.1.1.1   # 76.76.21.21     ← Cloudflare, correct

Two independent resolvers agreed on the new value. The change was live; only the local cache was behind. Nothing needed fixing.

Reading a TTL

The number before IN A is the TTL — how many seconds a resolver is allowed to keep this answer before asking again.

;; ANSWER SECTION:
ai-teacher.in.    600    IN    A    13.248.243.5
                   ^
                   TTL: 600 seconds = 10 minutes

So the worst case for that record was ten minutes, and the honest answer to "why is it still wrong?" was "wait six more minutes."

Lower the TTL before you migrate, not after. Drop it to 300 a day ahead, make the change, then put it back. Once the old value is cached at a 24-hour TTL, nothing you do can un-cache it.

Editing records at the registrar when the nameservers point elsewhere. If NS says Cloudflare, the records in your GoDaddy panel are decorative. Check dig NS yourdomain first.

Forgetting the parking records. Adding the right A record while leaving the host's placeholder A records in place means DNS round-robins between your site and a parking page. Symptom: it works every other refresh.

Testing only on your own machine. Your laptop, your phone and your office router all cache independently. One of them being wrong tells you nothing.

Moving nameservers without copying MX. The website comes up and email silently stops. This is the expensive one.

Words to know

ResolverThe server that answers DNS questions for you and caches the answers. Usually your ISP, or 8.8.8.8 / 1.1.1.1.
Authoritative nameserverThe server that holds the real records for a domain. Named by the NS record.
TTLTime to live: seconds a resolver may cache an answer before asking again.
Apex / rootThe bare domain, written @ — ai-teacher.in with nothing in front.
PropagationThe informal name for caches expiring at different times. Nothing is actually being pushed anywhere.

In two minutes

Test yourself

1. You changed an A record. Google's resolver shows the new IP; your laptop shows the old one. What should you do?

  1. Change the record again
  2. Wait for the TTL to expire
  3. Move to different nameservers
  4. Clear the record and re-add it
Show the answer

Wait for the TTL to expire — Two independent public resolvers agreeing means the change is live. Your machine is holding a cached answer until its TTL runs out.

2. Why can the apex of a domain not use a CNAME?

  1. CNAMEs are slower
  2. A CNAME cannot coexist with other records, and the apex always has NS and SOA
  3. The apex only supports IPv6
  4. Registrars charge extra
Show the answer

A CNAME cannot coexist with other records, and the apex always has NS and SOA — The spec forbids it. That is why hosts give you a literal A record for the root and a CNAME for www.

3. When should you lower a record's TTL before a migration?

  1. Immediately after switching
  2. A day or so before switching
  3. It makes no difference
  4. Only for CNAMEs
Show the answer

A day or so before switching — Lowering it afterwards is useless — resolvers already cached the old value at the old, longer TTL.

4. Which record type decides where email for your domain is delivered?

  1. TXT
  2. CNAME
  3. NS
  4. MX
Show the answer

MX — MX (mail exchanger) records name the mail servers. TXT is tempting because SPF and DKIM live there, but those only authenticate senders; they don't route delivery.

5. After pointing your domain at a new host, the site loads correctly on one refresh and shows a parking page on the next, alternating. What's the cause?

  1. A leftover parking A record still sits beside the new one, so resolvers rotate between them
  2. The TTL is too low
  3. The apex is a CNAME
  4. The browser cache is corrupt
Show the answer

A leftover parking A record still sits beside the new one, so resolvers rotate between them — Two A records for one name means round-robin: clients get either IP. Alternating results is the signature. A cache problem gives a consistently old answer, not a flip-flop.

6. You edit the A record in your GoDaddy panel. dig NS yourdomain shows Cloudflare nameservers. What happens?

  1. The change takes effect after the TTL
  2. GoDaddy forwards the change to Cloudflare
  3. Nothing — Cloudflare is authoritative, so the GoDaddy records are ignored; edit them in Cloudflare
  4. The two sets of records are merged
Show the answer

Nothing — Cloudflare is authoritative, so the GoDaddy records are ignored; edit them in Cloudflare — Resolvers only ask the nameservers listed in NS. Records at the registrar are decorative once NS points elsewhere. This wastes hours because the panel shows your change as 'saved'.

There are 8 questions, 3 puzzles and 5 recall cards for this lesson in the app — the recall cards come back on later days, just before you would forget.

Learn it so it stays. Read it, test yourself, then recall it on two different days. The app schedules that for you, free.

Start this lesson →