tutorialDNSDomainsTutorial

DNS and Domains Explained for Web Developers

DNS and Domains Explained for Web Developers

DNS is the phone book of the internet. It translates domain names (google.com) into IP addresses (142.250.80.46). Here's what developers need to know.


How DNS Works

When you type example.com in a browser:

1. Browser checks cache

2. OS checks cache

3. Query goes to DNS resolver (ISP or 8.8.8.8)

4. Resolver asks root servers → .com servers → example.com nameservers

5. IP address returned

6. Browser connects to that IP

All this happens in milliseconds.


Key Terminology

Domain Name

The human-readable address: example.com

Parts:

  • com - Top-level domain (TLD)
  • example - Second-level domain
  • www - Subdomain (optional)

Registrar

Where you buy domains: Namecheap, Cloudflare, GoDaddy, etc.

Nameservers

The servers that know your domain's DNS records:

ns1.example.com

ns2.example.com

DNS Records

Entries that tell computers where to find things.


Common DNS Records

A Record

Maps domain to IPv4 address.

Type: A

Name: @

Value: 76.76.21.21

TTL: 3600

@ means the root domain (example.com).

Use for: Pointing domain to a server IP.

AAAA Record

Maps domain to IPv6 address.

Type: AAAA

Name: @

Value: 2606:4700::1

Use for: IPv6 support.

CNAME Record

Alias one domain to another.

Type: CNAME

Name: www

Value: example.com

Use for: Making www.example.com go to example.com.

Important: CNAME cannot be used on root domain (@).

MX Record

Mail server configuration.

Type: MX

Name: @

Value: mail.example.com

Priority: 10

Use for: Email delivery. Priority determines preference (lower = higher priority).

TXT Record

Text information for verification and security.

Type: TXT

Name: @

Value: "v=spf1 include:_spf.google.com ~all"

Use for:

  • SPF (email security)
  • DKIM (email signing)
  • Domain verification
  • DMARC policies

NS Record

Specifies nameservers for the domain.

Type: NS

Name: @

Value: ns1.vercel-dns.com

Use for: Delegating DNS to a provider.


Common Configurations

Pointing Domain to Vercel

Option 1: A Record

Type: A

Name: @

Value: 76.76.21.21

Type: CNAME

Name: www

Value: cname.vercel-dns.com

Option 2: Nameservers (Recommended)

Update nameservers at registrar to:

ns1.vercel-dns.com

ns2.vercel-dns.com

Vercel then manages all DNS.

Pointing Domain to Netlify

Type: A

Name: @

Value: 75.2.60.5

Type: CNAME

Name: www

Value: example.netlify.app

Pointing Domain to Cloudflare Pages

Type: CNAME

Name: @

Value: example.pages.dev

(Cloudflare allows CNAME at root)

Email with Google Workspace

Type: MX

Name: @

Priority: 1

Value: smtp.google.com

Type: MX

Name: @

Priority: 5

Value: smtp2.google.com

Type: TXT

Name: @

Value: "v=spf1 include:_spf.google.com ~all"


TTL (Time to Live)

How long resolvers cache records (in seconds).

TTLDurationUse Case
601 minuteDuring DNS changes
36001 hourStandard
8640024 hoursStable records

Before changing DNS: Lower TTL first, wait, then change.

After changes work: Increase TTL for performance.


DNS Propagation

When you change DNS, it takes time to spread globally.

Why?

DNS resolvers cache records based on TTL. Until old cache expires, some users see old records.

How Long?

ScenarioTypical Time
Low TTL (60s)Minutes
Standard TTL1-4 hours
High TTLUp to 48 hours

What If Old DNS Not Propagating?

1. Wait longer

2. Try different DNS (8.8.8.8, 1.1.1.1)

3. Clear local DNS cache:

- Mac: sudo dscacheutil -flushcache

- Windows: ipconfig /flushdns


Debugging DNS

Command Line Tools

dig (Mac/Linux):

dig example.com A

dig example.com MX

dig example.com TXT

dig +short example.com

nslookup (Windows):

nslookup example.com

nslookup -type=MX example.com

Online Tools

What to Check

1. A record exists and is correct

2. Nameservers are set properly

3. No conflicting records

4. TTL is reasonable


Subdomains

Subdomains are prefixes to your domain:

  • blog.example.com
  • app.example.com
  • staging.example.com

Creating Subdomains

Add DNS records with the subdomain name:

Type: A

Name: blog

Value: 192.168.1.1

Or CNAME:

Type: CNAME

Name: staging

Value: staging-app.vercel.app

Wildcard Subdomains

Match any subdomain:

Type: A

Name: *

Value: 192.168.1.1

Now anything.example.com points to that IP.


SSL/HTTPS

Modern hosting provides free SSL:

ProviderSSL
VercelAutomatic
NetlifyAutomatic
CloudflareAutomatic
Let's EncryptFree, needs setup

With platforms like Vercel, just point your domain and SSL is issued automatically.


Common Mistakes

CNAME at Root

BAD - Won't work on all providers

Type: CNAME

Name: @

Value: example.vercel.app

Use A record for root domain unless provider supports CNAME flattening (Cloudflare does).

Conflicting Records

BAD - Both A and CNAME for www

Type: A

Name: www

Value: 192.168.1.1

Type: CNAME

Name: www

Value: example.vercel.app

Only one can exist for the same name.

Wrong Priority on MX

Lower priority = higher preference:

Preferred mail server

Priority: 1

Value: smtp.google.com

Backup mail server

Priority: 10

Value: backup.google.com

Forgetting www

Configure both:

@ → A record to server

www → CNAME to @ or server


Buying Domains

Good Registrars

RegistrarPros
CloudflareAt-cost pricing, good DNS
NamecheapAffordable, free WHOIS privacy
PorkbunLow prices, quirky brand
Google DomainsSimple (now Squarespace)

Avoid

  • GoDaddy (expensive renewals, upsells)
  • Domain.com (high prices)

What to Look For

  • Free WHOIS privacy
  • Not inflated renewal prices
  • Easy DNS management
  • No price lock-in

Quick Reference

RecordPurposeExample Value
AIP address76.76.21.21
AAAAIPv6 address2606:4700::1
CNAMEAliasexample.vercel.app
MXMail serversmtp.google.com
TXTText data"v=spf1 ..."
NSNameserverns1.vercel-dns.com

Conclusion

DNS basics for developers:

1. A record = domain to IP

2. CNAME = alias to another domain

3. MX = email server

4. TXT = verification and email security

5. TTL = cache duration

6. Propagation = takes time after changes

Most modern platforms make this easy. Point your domain, they handle the rest.

Related guides:

Deploy your site →

Share:

Related Articles

View all

Ready to Migrate Your WordPress Site?

Use our free tool to export your WordPress content in minutes.

Start Free Migration