Domains and DNS explained
Part 3 of the Running your VPS series.
Almost every website guide says "point your domain at your server" and moves on. This guide explains what that actually means. It covers buying a domain, what DNS is, the records you will use, and the exact steps to connect a domain to a VPS or a hosting plan, with a troubleshooting table for when it does not work.
One honest limit: every domain registrar and DNS provider has its own screens. The ideas are the same everywhere, but you may need their help pages to find the right button.
Small VPS plans in stock, for your first website
- 1 GB KVM VPS Special1 CPU · 1 GB RAM · 20 GB disk · 3 TB bandwidth · New York, Los Angeles, Chicago$21.99/yrabout $1.83/moView at RackNerd
- Storage VPS Special - 100GB Storage1 CPU · 1 GB RAM · 100 GB disk · 10 TB bandwidth · Los Angeles, Dallas, Chicago$35.00/yrabout $2.92/moView at RackNerd
- 2 GB KVM VPS Special2 CPU · 2 GB RAM · 35 GB disk · 5 TB bandwidth · New York, Los Angeles, Chicago$35.99/yrabout $3.00/moView at RackNerd
- Ryzen-1GB (Linux)1 CPU · 1 GB RAM · 15 GB disk · 1 TB bandwidth · New York, Chicago, Seattle$194.29/yrabout $16.19/moView at RackNerd
In stock when this page loaded. See all 7 matching plans
What is in this guide
- A few words you will see
- How a domain finds a server
- Buying a domain
- The records you will use
- Where your DNS lives
- Pointing a domain at a VPS, step by step
- Pointing a domain at shared hosting
- Email records
- Common mistakes
- Troubleshooting
- Limits
- When to step up
- More in the series
A few words you will see
| Term | What it means |
|---|---|
| Domain | A name such as example.com, rented yearly from a registrar. |
| Registrar | The company you buy and renew the domain through. |
| DNS | The Domain Name System: the internet's address book, which turns names into IP addresses. |
| Nameservers | The servers that hold your domain's DNS records. Set at the registrar. |
| Record | One entry in DNS, such as "example.com points to this IP address". |
| TTL | Time to live: how long other computers may remember a record before checking again, in seconds. |
| Propagation | The time it takes for a change to be seen everywhere, as old cached answers expire. |
| @ | Shorthand in many DNS panels for the bare domain itself, such as example.com. |
How a domain finds a server
When someone types your domain into a browser, their computer asks DNS where it lives. DNS looks up which nameservers are responsible for your domain, asks them, and gets back an IP address. The browser then connects to that address.
So connecting a domain to a server takes two things: the domain must use nameservers you control, and those nameservers must have a record pointing to your server's IP address.
Buying a domain
- Domains are usually separate from hosting. You buy them from a registrar and renew them yearly. Some hosting plans include one, so check.
- Check the renewal price. Many registrars charge less for the first year. Look at what the second year costs.
- Turn on auto-renew and keep your contact email current. An expired domain takes your website and email offline, and it can be bought by someone else.
- Turn on two-factor login at the registrar. Whoever controls the domain controls your site and email.
- Look for privacy protection. Many registrars hide your personal details from public lookups, often for free.
- Buy it in your own name. If someone builds a site for you, the domain should still be registered to you.
If you do not have a registrar yet, NameSilo is one option. Compare first-year and renewal prices with other registrars before you choose, and check the points above whichever one you pick.
The records you will use
| Record | What it does | Example |
|---|---|---|
| A | Points a name to an IPv4 address | example.com to your server's IPv4 address |
| AAAA | Points a name to an IPv6 address | example.com to your server's IPv6 address |
| CNAME | Points a name to another name | www.example.com to example.com |
| MX | Says which server receives email for the domain | Given by your email provider |
| TXT | Holds text, used for email security and proving you own a domain | SPF, DKIM, DMARC and verification codes |
| NS | Says which nameservers hold the domain's records | Set at the registrar |
Two rules worth knowing. A CNAME cannot usually sit on the bare domain itself, only on names like www. And a name with a CNAME cannot have other records as well.
Where your DNS lives
Your DNS records are kept by whoever runs your nameservers. There are three common choices:
- The registrar's own DNS. The simplest option. Records are managed in the same account as the domain.
- Your hosting provider's nameservers. Common with shared and reseller hosting, where the control panel manages records for you.
- A separate DNS provider. Some people use a dedicated DNS service for speed or extra features.
Pick one place and keep all records there. Changing nameservers moves every record to the new place, so copy them first. This is the most common way people accidentally break their email.
Pointing a domain at a VPS, step by step
- Find your server's IP address. It is in the welcome email and the VPS control panel. Note the IPv4 address, and the IPv6 address if you have one.
- Open your DNS records. Log in wherever your DNS lives, usually the registrar.
- Add an A record for the bare domain. Name
@, type A, value your server's IPv4 address. - Add a record for www. Either a CNAME from
wwwto your domain, or a second A record forwwwwith the same IP address. - Add AAAA records if you use IPv6. Same names, with your IPv6 address. Only add them if your server is set up to serve the site over IPv6, or visitors on IPv6 will see errors.
- Set a sensible TTL. A short TTL, such as 300 seconds, makes changes take effect faster while you set up. You can raise it later.
- Wait, then check. New records often work within minutes, but changes can take longer to show everywhere. Check from your computer:
On Windows, usedig example.com A +short dig www.example.com +shortnslookup example.com. Both should show your server's IP address. - Set up the website on the server. Configure your web server to answer for the domain. See web servers or WordPress on a VPS.
- Add an SSL certificate last. Free certificate tools such as Certbot check that the domain points to your server, so they only work once DNS is correct.
Shared hosting plans in stock, if you would rather not run a server
- SHARED - 30 GB (Available in Multiple Locations)30 GB disk · 3 TB bandwidth · Los Angeles, New York, Frankfurt$10.49/yrabout $0.87/moView at RackNerd
- SHARED - 85 GB (Available in Multiple Locations)85 GB disk · 10 TB bandwidth · Los Angeles, New York, Frankfurt$24.99/yrabout $2.08/moView at RackNerd
- SHARED - 200 GB (Available in Multiple Locations)200 GB disk · 30 TB bandwidth · Los Angeles, New York, Frankfurt$59.00/yrabout $4.92/moView at RackNerd
In stock when this page loaded. See all 7 matching plans
Pointing a domain at shared hosting
With shared or reseller hosting, you usually have two options. The welcome email or the provider's knowledge base tells you which details to use.
- Change the nameservers at your registrar to the hosting provider's. The hosting control panel then creates the website and email records for you. Easiest for beginners.
- Keep your current DNS and add an A record pointing to the hosting account's IP address. Better if you already have other records, such as email at another service, that you want to keep in one place.
Resellers may be able to use their own branded nameservers. Reseller hosting for freelancers covers this.
Email records
If you use email on your own domain, a few records decide where mail goes and whether it is trusted.
- MX records tell other servers where to deliver your mail.
- SPF, a TXT record, lists which servers may send mail for your domain.
- DKIM, a TXT record, holds a key that signs your outgoing mail.
- DMARC, a TXT record, tells receivers what to do with mail that fails the checks.
Your email provider gives you the exact values. Copy them carefully. Running your own mail server on a VPS is hard to do well, and mail from new servers often lands in spam. For most people, an email service or the email included with shared hosting is the better choice.
One more: reverse DNS, or a PTR record, maps an IP address back to a name. It matters mainly for sending email. It is set by whoever owns the IP address, so on a VPS it is usually changed through the control panel or by asking support, not at your registrar.
Common mistakes
- Changing nameservers without copying records. Email and other services stop working. Copy every record to the new place first.
- Typos in the IP address. Copy and paste it rather than typing.
- Adding the domain twice. Some panels add the domain for you. Entering
example.comas the name can create example.com.example.com. Use@or leave the name blank, as the panel's help says. - Forgetting www. Many visitors type it. Add a record for it.
- An old AAAA record. If an AAAA record points somewhere else, IPv6 visitors go there instead of your server.
- Letting the domain expire. Turn on auto-renew.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
dig shows the old IP address | The old record is still cached | Wait for the old TTL to run out. Check the record is saved correctly |
dig shows nothing | Record missing, or the nameservers are not the ones you edited | Run dig example.com NS +short and edit records where those nameservers live |
| Domain works but www does not | No record for www | Add a CNAME or A record for www |
| DNS is correct but the site does not load | Web server not set up for the domain, or the firewall blocks ports 80 and 443 | Check the web server config and run sudo ufw status |
| Certificate tool fails | DNS not pointing to this server yet, or port 80 blocked | Fix DNS first, wait, then try again |
| Email stopped after a change | MX or other email records lost when nameservers changed | Add the email provider's records again at the new DNS |
| Works for you, not for others | Caches differ around the world | Wait a few hours and test from another network |
Limits
- Panels differ. Your registrar may name fields differently. The record types are the same.
- Propagation is not instant. It usually takes minutes, but can take longer, and nobody can force it to be faster.
- DNS is not security. Hiding a server's address in DNS does not protect it. Secure the server itself. See securing your VPS.
- Domain rules vary. Some country domains have their own rules about who may register them.
When to step up
A domain works the same whether it points at a 1 GB VPS or a dedicated server. If your site has outgrown its server, you can point the domain at a bigger one by changing one record. Moving to a new VPS explains how to do that with little or no downtime.
2 GB and 4 GB VPS plans in stock, for a growing site
- 2 GB KVM VPS Special2 CPU · 2 GB RAM · 35 GB disk · 5 TB bandwidth · New York, Los Angeles, Chicago$35.99/yrabout $3.00/moView at RackNerd
- 4 GB KVM VPS Special3 CPU · 4 GB RAM · 60 GB disk · 7 TB bandwidth · New York, Los Angeles, Chicago$59.99/yrabout $5.00/moView at RackNerd
- Ryzen-2GB (Linux)2 CPU · 2 GB RAM · 20 GB disk · 2 TB bandwidth · New York, Chicago, Seattle$222.37/yrabout $18.53/moView at RackNerd
- KVM-2GB3 CPU · 2 GB RAM · 75 GB disk · 2 TB bandwidth · Los Angeles, Dallas, Chicago$247.08/yrabout $20.59/moView at RackNerd
In stock when this page loaded. See all 6 matching plans
To compare what is available now, start with the cheapest RackNerd VPS guide and check the sales page.
More in the series
This is part 3 of 5. Previous: VPS or dedicated server?. Next: Moving to a new VPS. See the whole series.