Cloud VPS from $1.98/mo · pay with Bitcoin, Ethereum, Monero, USDT or Solana · paid in crypto
Networking

Point a domain to your server with A and AAAA records

Point a domain at a VPS: A and AAAA records, www and the apex, nameserver changes, TTL planning, checks with dig, CAA, and reverse DNS for the server's IP.

CloudSat teamNovember 18, 20266 min read
Abstract illustration of a domain name tag connected by a thin luminous thread to a single server in a field of dots
On this pageWhat you need first

Pointing a domain at a server means publishing a few DNS records that turn a name into the server's IP addresses. The records take a minute to create. Most of the trouble comes from editing them in the wrong place, from caches that remember the old answer, and from forgetting the second name (www or the bare domain). This guide does it in the order that avoids all three.

What you need first

  • The server's public IPv4 address, and its IPv6 address if it has one. On CloudSat both are on the server's Overview tab, as described in Your server IPv4 and IPv6 addresses.
  • Access to the dashboard where the domain's DNS is hosted. That is not always the registrar.
  • A web server, or whatever service the name is for, already answering on the IP address.

Find out who answers for the domain

The registrar is where you bought the domain. The DNS host is whoever runs the nameservers listed for it, which can be the registrar, a CDN, or a DNS provider. Records only take effect where the nameservers point. Ask the public DNS which ones that is:

dig +short NS example.com
whois example.com | grep -i 'name server'

On Windows, Resolve-DnsName example.com -Type NS gives the same answer. If the names belong to your registrar, edit records there. If they belong to another company, edit records in that company's dashboard; changes at the registrar will have no effect.

Two ways to point a domain

Method What you change Speed Use it when
Edit records at the current DNS host A and AAAA records Minutes, limited by the old TTL Almost always
Change the nameservers NS delegation at the registrar Up to a day or two You are moving DNS hosting itself

Changing nameservers moves the whole zone, so every record (mail, verification, subdomains) must exist at the new host before you switch. The delegation lives in the top-level domain's servers, whose cached answers commonly last a day or two, so plan for that window.

Create the records

A website usually needs four records: the bare domain (the apex) and www, each for IPv4 and IPv6.

Name Type Value TTL
@ (example.com) A 203.0.113.10 3600
@ (example.com) AAAA 2001:db8:10:20::2 3600
www A 203.0.113.10 3600
www AAAA 2001:db8:10:20::2 3600

Most dashboards write the apex as @ or leave the name empty. Instead of separate www addresses, you can make www a CNAME pointing at example.com, so a later IP change touches only the apex records. The apex itself cannot be a CNAME, because the DNS rules forbid one next to the zone's other records; some providers offer ALIAS, ANAME or "flattened" records as a workaround when the target must be a hostname.

Only publish an AAAA record when the service really answers on IPv6. A wrong IPv6 address is worse than none: visitors with IPv6 try it first and wait before falling back.

Plan the TTL

The TTL (time to live) tells resolvers how many seconds they may cache an answer. It is why "DNS propagation" takes time: nothing is pushed around the internet, resolvers simply keep the old answer until it expires.

For a planned move, lower the TTL on the existing records to 300 seconds at least one full old-TTL period before the change. After the switch, resolvers pick up the new address within about five minutes. Raise the TTL again, to an hour or more, once everything works.

Resolvers also cache the fact that a name does not exist. If someone looked up www before you created it, they may keep getting a "no such domain" answer for a while; the NXDOMAIN guide explains how long and why.

Check the result from the source

Ask the authoritative nameserver directly, which shows what you published without any cache in between, then compare with a public resolver:

dig +short example.com A @ns1.dnshost.example
dig +short www.example.com AAAA @ns1.dnshost.example
dig +short example.com A @1.1.1.1
dig +trace www.example.com

Replace ns1.dnshost.example with one of the names from the NS query. If the authoritative answer is right and a public resolver still shows the old address, it is caching and will catch up within the old TTL. +trace follows the delegation from the root servers down and shows exactly where a chain breaks. More query techniques are in nslookup, dig and Resolve-DnsName.

Make the server answer for the name

DNS only brings visitors to the IP address. The web server must also accept the name, or visitors see a default page or the wrong site. In nginx that is the server_name line:

server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;
    root /var/www/example.com;
}

Run sudo nginx -t && sudo systemctl reload nginx, test with curl -I http://example.com, and then add HTTPS, which needs the DNS records to be correct before a certificate can be issued. The steps are in fix the Not secure warning.

Two records worth adding

CAA lists which certificate authorities may issue certificates for your domain. One record for the authority you actually use blocks issuance by any other:

example.com.  3600  IN  CAA  0 issue "letsencrypt.org"

Reverse DNS (a PTR record) maps the IP address back to a name. Web visitors never see it, but mail servers check it, and logs and tracing tools become easier to read. It is set by whoever owns the IP address, not in your domain's zone. On CloudSat that is the Networking tab of the server, covered in Set reverse DNS for your IPv4.

When it does not work

  • The old site still appears. The authoritative server is right, but your machine or resolver caches the old answer. Wait out the TTL or flush the DNS cache.
  • The authoritative server shows nothing. The record was created at a host that is not authoritative for the domain. Compare the NS records with the dashboard you used.
  • A typo in the record name. Some dashboards append the domain automatically, so entering www.example.com creates www.example.com.example.com.
  • The name resolves, but the connection times out. DNS is fine; a firewall in front of the server blocks the port.

FAQ

How long does a DNS change take?

A changed record is visible everywhere once the previous TTL has passed, usually minutes to an hour. A nameserver change can take a day or two because of the top-level domain's caching.

Should I use the registrar's DNS or a separate DNS host?

Either works. A separate DNS host can make sense if you want features such as an API for automation, but keeping DNS with the registrar is simpler for a single site.

What happens to my email when I change the A record?

Nothing, as long as the MX records stay as they are. Mail follows MX records, not the web address, unless the MX points at the same name whose address you changed.

Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.