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

In stock when this page loaded. See all 7 matching plans

What is in this guide

A few words you will see

TermWhat it means
DomainA name such as example.com, rented yearly from a registrar.
RegistrarThe company you buy and renew the domain through.
DNSThe Domain Name System: the internet's address book, which turns names into IP addresses.
NameserversThe servers that hold your domain's DNS records. Set at the registrar.
RecordOne entry in DNS, such as "example.com points to this IP address".
TTLTime to live: how long other computers may remember a record before checking again, in seconds.
PropagationThe 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

RecordWhat it doesExample
APoints a name to an IPv4 addressexample.com to your server's IPv4 address
AAAAPoints a name to an IPv6 addressexample.com to your server's IPv6 address
CNAMEPoints a name to another namewww.example.com to example.com
MXSays which server receives email for the domainGiven by your email provider
TXTHolds text, used for email security and proving you own a domainSPF, DKIM, DMARC and verification codes
NSSays which nameservers hold the domain's recordsSet 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

  1. 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.
  2. Open your DNS records. Log in wherever your DNS lives, usually the registrar.
  3. Add an A record for the bare domain. Name @, type A, value your server's IPv4 address.
  4. Add a record for www. Either a CNAME from www to your domain, or a second A record for www with the same IP address.
  5. 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.
  6. 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.
  7. Wait, then check. New records often work within minutes, but changes can take longer to show everywhere. Check from your computer:
    dig example.com A +short
    dig www.example.com +short
    On Windows, use nslookup example.com. Both should show your server's IP address.
  8. Set up the website on the server. Configure your web server to answer for the domain. See web servers or WordPress on a VPS.
  9. 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

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.com as 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

SymptomLikely causeFix
dig shows the old IP addressThe old record is still cachedWait for the old TTL to run out. Check the record is saved correctly
dig shows nothingRecord missing, or the nameservers are not the ones you editedRun dig example.com NS +short and edit records where those nameservers live
Domain works but www does notNo record for wwwAdd a CNAME or A record for www
DNS is correct but the site does not loadWeb server not set up for the domain, or the firewall blocks ports 80 and 443Check the web server config and run sudo ufw status
Certificate tool failsDNS not pointing to this server yet, or port 80 blockedFix DNS first, wait, then try again
Email stopped after a changeMX or other email records lost when nameservers changedAdd the email provider's records again at the new DNS
Works for you, not for othersCaches differ around the worldWait 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

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.

More RackNerd guides