
TL;DR
|
DNS is the internet's address book. When you type a website's name into a browser, DNS looks up where that website actually lives and sends the browser there.
Many people only deal with DNS when connecting a domain to a website or an email service, and then the jargon arrives all at once: A records, CNAMEs, TXT records, TTLs. This guide explains how DNS works, what the common record types do, and how to point a domain at your site.
Key takeaway: DNS looks up a domain name and returns the address of the server behind it, then remembers the answer for a while.
Computers find each other using IP addresses, such as 203.0.113.10. People use names, such as example.com. DNS connects the two. When you visit a site:
The authoritative name server is usually run by your DNS provider, which is often the company you bought the domain from, called the registrar. Its settings are where you add and edit your domain's records.
Key takeaway: each record type answers a different question about a domain.
| Record | What it does | Example |
|---|---|---|
| A | Points a name to an IPv4 address | example.com → 203.0.113.10 |
| AAAA | Points a name to an IPv6 address | example.com → 2001:db8::10 |
| CNAME | Points a name to another name, which is then looked up in turn | www.example.com → example.hosting-provider.com |
| MX | Says which servers receive email for the domain | example.com → mail.example.com |
| TXT | Holds text, used for verification and email security | v=spf1 include:_spf.example.net ~all |
| NS | Says which name servers are authoritative for the domain | example.com → ns1.dns-provider.com |
| CAA | Says which certificate authorities may issue certificates for the domain | example.com → letsencrypt.org |
| ALIAS or ANAME | Works like a CNAME but can be used on the bare domain. Offered by some providers, not part of the DNS standard | example.com → example.hosting-provider.com |
Key takeaway: an A record points to a fixed address. A CNAME points to a name, so it follows the address wherever it moves.
An A record says "this name lives at this IP address". It's simple, but if the server's address changes, you have to update the record yourself.
A CNAME says "this name is the same as that other name". The lookup follows the other name to find the address. Hosting platforms often ask for a CNAME, because they can move your site to new servers and update their own name without you changing anything.
There's one important restriction: a CNAME can't sit on the bare domain, also called the apex or root, such as example.com. The apex must hold other records, such as the domain's name servers, and the DNS rules don't allow a CNAME alongside them. That's why providers created ALIAS and ANAME records, which behave like a CNAME but are allowed at the apex.
Key takeaway: TXT records let services check that you control a domain, and they protect your domain's email from being faked.
A TXT record holds a piece of text that other services read. Common uses include:
| Use | What the TXT record contains |
|---|---|
| Proving ownership | A code from a service, such as a search console or certificate provider, that shows you control the domain |
| SPF | A list of servers allowed to send email for your domain |
| DKIM | A public key that lets receivers check your emails weren't altered |
| DMARC | Instructions for what receivers should do with email that fails those checks |
A domain can have many TXT records at once, so adding one for a new service doesn't affect the others.
Key takeaway: DNS answers are remembered for a set time, so changes can take a while to reach everyone.
Every record has a TTL, short for time to live: the number of seconds resolvers may remember it. A TTL of 3600 means one hour. Until it runs out, some visitors may still be sent to the old address after you change a record. This delay is often called DNS propagation.
Before changing an important record, lower its TTL a day ahead, for example to 300 seconds. Make the change, check everything works, then raise the TTL again.
Key takeaway: many DNS problems come from conflicting records, the apex rule, or impatience.
| Mistake | What happens | How to avoid it |
|---|---|---|
| A CNAME on the bare domain | The provider rejects it, or email and other records stop working | Use an ALIAS or ANAME record, or redirect the bare domain to www |
| A and CNAME records for the same name | Conflicting answers, or the provider refuses the change | Keep one type of record per name |
| Forgetting the www version | example.com works but www.example.com doesn't, or the other way around | Add records for both, and redirect one to the other |
| Changing records with a long TTL | Visitors reach the old server for hours | Lower the TTL before the change |
| Deleting old TXT records | Email starts landing in spam, or a service loses verification | Check what each TXT record is for before removing it |
Key takeaway: on Upsun Cloud, you point your domain at your project's target address with a CNAME record, then add the domain to the project.
The Upsun docs on setting up a custom domain describe three steps.
1. Get your project's target. Run upsun environment:info edge_hostname, or copy the CNAME record value from your production environment's Domains settings in the Console.
2. Add DNS records at your DNS provider. Lower the TTL first, then point your domain at the target: an ALIAS or ANAME record for the bare domain, and a CNAME for www if you use it:
| Name | Record type | Points to |
|---|---|---|
| example.com | ALIAS or ANAME | Your project's target |
| www.example.com | CNAME | Your project's target |
If your provider doesn't allow any of these on the bare domain, the docs describe workarounds: forwarding the bare domain to www, or using a redirection service.
3. Add the domain to your project. Run upsun domain:add example.com, or add it under Domains in the Console.
Once DNS points to your project and your routes use HTTPS, Upsun Cloud issues a free certificate for the domain automatically. Our guide What is an SSL/TLS certificate? explains how that works. A few details from the docs are worth knowing:
You can deploy on Upsun Cloud free for 15 days, with no card needed, or read the full guide to setting up a custom domain.
Domain Name System. It translates domain names into the IP addresses computers use to connect.
An A record points a name directly to an IP address. A CNAME points a name to another name, whose address is then looked up.
The root domain must hold other records, such as its name servers, and DNS rules don't allow a CNAME alongside other records. Use an ALIAS or ANAME record if your provider offers one, or redirect the root domain to www.
Often minutes, but it can take up to a couple of days, depending on the record's TTL and how long resolvers remember old answers.
Proving you own a domain to services such as search consoles and certificate providers, and protecting your email with SPF, DKIM, and DMARC.
Use an online DNS lookup tool, or run dig example.com on macOS or Linux, or nslookup example.com on Windows.