DNS Setup Explained: A Beginner's Guide to Connecting Your Domain
What Is DNS and Why Does It Matter?
DNS stands for Domain Name System, and it's essentially the phone book of the internet. When someone types `yourdomain.com` into their browser, DNS translates that human-readable name into an IP address like `104.21.35.192` โ the actual server address where your website lives.
Without DNS, you'd have to memorize numerical IP addresses for every website you visit. DNS makes the internet usable by letting us work with names instead of numbers.
Understanding DNS is essential for anyone who owns a domain name. Whether you're launching a website, setting up email, or connecting a domain to a hosting provider, DNS configuration is the bridge between your domain and the services behind it.
Key DNS Concepts You Need to Know
Nameservers
Nameservers are the first stop in DNS resolution. They're the servers that hold your domain's DNS records and answer queries about where to find your website, email server, and other services.
When you register a domain, it's assigned default nameservers by your registrar. You can change these to point to a different DNS provider โ like Cloudflare, your hosting company, or a dedicated DNS service.
Nameservers typically look like:
```
ns1.example.com
ns2.example.com
```
You always need at least two nameservers for redundancy. If one goes down, the other continues answering DNS queries.
DNS Records
DNS records are individual instructions stored on your nameservers. Each record type serves a different purpose. Think of them as rows in a lookup table that tell the internet where to route different types of traffic for your domain.
TTL (Time to Live)
Every DNS record has a TTL value measured in seconds. This tells other DNS servers how long to cache (remember) the record before checking for updates. Common values:
- 300 seconds (5 minutes) โ good for records you change frequently
- 3600 seconds (1 hour) โ standard for most records
- 86400 seconds (24 hours) โ for records that rarely change
When you're about to make DNS changes, lower the TTL a day in advance so the switch happens faster.
Essential DNS Record Types
A Record
The A record is the most fundamental DNS record. It maps your domain name to an IPv4 address.
```
Type: A
Name: @ (or yourdomain.com)
Value: 104.21.35.192
TTL: 3600
```
The `@` symbol represents your root domain. If your website is hosted at IP address `104.21.35.192`, you create an A record pointing there.
You can also create A records for subdomains:
```
Type: A
Name: blog
Value: 104.21.35.192
TTL: 3600
```
This makes `blog.yourdomain.com` resolve to that IP address.
AAAA Record
The AAAA record is identical to the A record but for IPv6 addresses:
```
Type: AAAA
Name: @
Value: 2606:4700:3030::6815:23c0
TTL: 3600
```
As the internet transitions to IPv6, adding AAAA records alongside your A records ensures compatibility with modern networks.
CNAME Record
A CNAME (Canonical Name) record creates an alias that points one domain name to another domain name โ not an IP address.
```
Type: CNAME
Name: www
Value: yourdomain.com
TTL: 3600
```
This makes `www.yourdomain.com` resolve to wherever `yourdomain.com` points. CNAMEs are commonly used for:
- Pointing `www` to your root domain
- Connecting to hosted services (e.g., `shop.yourdomain.com` โ `shops.myshopify.com`)
- Setting up CDN services
Important limitation: You cannot create a CNAME record for your root domain (`@`) at most DNS providers. Use an A record or look for providers that support CNAME flattening (like Cloudflare).
MX Record
MX (Mail Exchange) records tell the internet where to deliver email for your domain. Without MX records, email sent to `[email protected]` has nowhere to go.
```
Type: MX
Name: @
Value: mail.yourdomain.com
Priority: 10
TTL: 3600
```
MX records include a priority number. Lower numbers mean higher priority. If you have multiple mail servers, email tries the lowest-priority server first and falls back to others if it's unavailable:
```
Priority 10: ASPMX.L.GOOGLE.COM
Priority 20: ALT1.ASPMX.L.GOOGLE.COM
Priority 30: ALT2.ASPMX.L.GOOGLE.COM
```
TXT Record
TXT records store text-based information. They're used for various verification and security purposes:
- SPF โ Specifies which servers can send email for your domain
- DKIM โ Adds email authentication signatures
- DMARC โ Defines email authentication policies
- Domain verification โ Proves you own the domain to services like Google, Microsoft, or Facebook
Example SPF record:
```
Type: TXT
Name: @
Value: v=spf1 include:_spf.google.com ~all
TTL: 3600
```
NS Record
NS records specify the authoritative nameservers for your domain. These are usually set at your registrar and rarely need manual editing:
```
Type: NS
Name: @
Value: ns1.cloudflare.com
TTL: 86400
```
Common DNS Setup Scenarios
Connecting a Domain to Web Hosting
The most common DNS task is pointing your domain to a web host. You have two approaches:
Option 1: Change nameservers (recommended for most users)
- Log into your hosting provider and find their nameservers
- Log into your domain registrar
- Replace the default nameservers with your host's nameservers
- Wait for propagation (up to 48 hours, usually much faster)
Option 2: Add A/CNAME records
- Keep your current nameservers
- Add an A record pointing `@` to your host's IP address
- Add a CNAME record pointing `www` to your domain
- Changes propagate based on your TTL setting
Setting Up Cloudflare
Cloudflare is a popular DNS provider that adds CDN, security, and performance features. Setup:
- Create a free Cloudflare account
- Add your domain
- Cloudflare scans your existing DNS records and imports them
- Update your nameservers at your registrar to Cloudflare's nameservers
- Manage all DNS records through Cloudflare's dashboard
Many domain owners find their domains at domydomains.com and then route them through Cloudflare for the best combination of price and performance.
Pointing a Subdomain to a Different Service
You might want `blog.yourdomain.com` on WordPress while your main site runs on a different platform:
```
Type: CNAME
Name: blog
Value: yoursite.wordpress.com
TTL: 3600
```
Or point `shop.yourdomain.com` to Shopify:
```
Type: CNAME
Name: shop
Value: shops.myshopify.com
TTL: 3600
```
Setting Up a Domain Redirect
To redirect `olddomain.com` to `newdomain.com`, you typically need:
- An A record pointing to a server that handles the redirect
- A redirect rule on that server (HTTP 301 redirect)
Some DNS providers like Cloudflare offer redirect rules directly in their dashboard without needing a separate server.
DNS Propagation: Why Changes Aren't Instant
When you update DNS records, the changes don't take effect worldwide immediately. DNS propagation is the time it takes for DNS servers around the world to update their cached records.
How Long Does Propagation Take?
- Same DNS provider changes: Usually minutes
- Nameserver changes: 1โ48 hours, typically under 4 hours
- Record updates with low TTL: Minutes to hours
- Record updates with high TTL: Up to the TTL value
Checking Propagation Status
Use tools like `dig` (command line) or online checkers like whatsmydns.net to verify your DNS changes from multiple locations:
```bash
dig yourdomain.com A +short
dig yourdomain.com MX +short
dig yourdomain.com TXT +short
```
DNS Security Best Practices
Enable DNSSEC
DNSSEC (DNS Security Extensions) adds cryptographic signatures to your DNS records, preventing attackers from intercepting and modifying DNS responses. Most modern registrars support DNSSEC โ enable it in your domain settings.
Use a Reputable DNS Provider
Free DNS from your registrar works, but dedicated DNS providers offer better performance, uptime, and security:
- Cloudflare โ Free tier with excellent performance and DDoS protection
- AWS Route 53 โ Highly reliable, pay-per-query pricing
- Google Cloud DNS โ Fast and globally distributed
Lock Your Domain
Enable registrar lock (transfer lock) to prevent unauthorized DNS changes or domain transfers. This is a basic security measure every domain owner should use.
Monitor DNS Changes
Set up alerts for unexpected DNS changes. Some DNS providers offer audit logs that track who changed what and when.
Troubleshooting Common DNS Issues
Website Not Loading After DNS Change
- Wait for propagation โ give it at least a few hours
- Clear your local DNS cache โ `ipconfig /flushdns` on Windows, `sudo dscacheutil -flushcache` on macOS
- Check the record values โ typos in IP addresses are a common cause
- Verify nameservers โ ensure they're pointing to the right provider
Email Not Working
- Check MX records โ ensure they're correctly configured for your email provider
- Verify SPF/DKIM/DMARC โ missing authentication records cause delivery failures
- Check for conflicting records โ multiple MX configurations can cause issues
Subdomain Not Resolving
- Verify the record exists โ check for the specific A or CNAME record
- Check for typos โ the subdomain name must match exactly
- Confirm the target is correct โ ping the target IP or hostname to verify it's reachable
Getting Started
DNS might seem intimidating at first, but it's fundamentally a simple system of records that map names to addresses. Start with the basics โ an A record for your website and MX records for email โ and build from there.
If you don't have a domain yet, search for one at domydomains.com and compare registrar prices. Once you've registered your domain, follow this guide to connect it to your website and email provider. Within an hour, you'll have a fully functional domain powering your online presence.