All articles
  1. Home
  2. Blog
  3. Tutoriels
Tutoriels

How to Point a Domain to a VM: DNS Setup in 6 Steps

Point your domain at a cloud VM in six steps: find your DNS host, add A and AAAA records, set up www, confirm with dig, then configure your web server and free HTTPS. Includes records you can copy and fixes for common problems.

Illustration of a domain name connected to a cloud server, showing how to point a domain to a VM

To point a domain to a VM, you create an A record at your DNS provider that maps the domain to the VM's public IP address. Add an AAAA record if the VM has IPv6, and a record for www. Then you wait for old DNS caches to expire, check the result with dig, and set up your web server and HTTPS. The DNS part takes only a few minutes of work.

What you need before you start

Gather four things before you touch any records. It saves you from debugging the wrong layer later.

  • A registered domain, for example from the FelCloud domains page or any other registrar.
  • Access to the DNS panel wherever the domain's nameservers live.
  • A running VM with a public IP address, such as a FelCloud cloud VM.
  • SSH access to the VM, so you can configure the web server.

Find out who hosts your DNS (your nameservers)

Your registrar and your DNS host are not always the same company. The DNS host is whoever runs your domain's nameservers. You edit records there, not anywhere else. Check them from a terminal:

dig NS example.com +short

If the answer shows your registrar's nameservers, edit DNS in the registrar's panel. If it shows another provider, such as Cloudflare, edit records there. Changing records in the wrong panel is the most common reason "nothing happens".

Make sure your VM has a static IP address

DNS records point at an IP, not at a machine. If the VM's public IP changes when you stop or rebuild it, your site goes offline. Many clouds offer a reserved or static IP address that stays the same. Reserve one before you point a domain to a VM, so the records you publish stay valid. Note the IPv4 address and, if available, the IPv6 address.

Which DNS records point a domain to a VM?

Only two or three record types matter for this job. The table below shows what each one does. The full list lives in the Wikipedia list of DNS record types.

RecordMaps a name toUse it forExample value
A recordAn IPv4 addressThe root domain and any subdomain203.0.113.10
AAAA recordAn IPv6 addressThe same names, if your VM has IPv62001:db8::10
CNAME recordAnother domain nameSubdomains like www that should follow the rootexample.com.
MX recordA mail server nameEmail only, so leave it alone here10 mail.example.com.

Why you can't use a CNAME record at the root

A name that has a CNAME record cannot hold any other records. The root of your domain (often written as @) must always hold SOA and NS records, so it cannot be a CNAME. This rule comes from RFC 1034, section 3.6.2. Use an A record for the root. A CNAME record works well for www.

How to point a domain to a VM in 6 steps

Here is the full process to point a domain to a VM. It works the same for .com, .tn, .tech or any other extension.

  1. Lower the TTL a day ahead. If you are moving from an old server, set the existing records' TTL to 300 seconds. Wait at least as long as the old TTL before you switch.
  2. Add an A record for the root. Host @, value = your VM's IPv4 address.
  3. Add an AAAA record for the root, but only if the VM really answers on IPv6.
  4. Add www. Use a CNAME record pointing to the root, or a second A record with the same IP.
  5. Delete conflicting records. Remove old A, AAAA or "parking" records on the same names. Two A records with different IPs split your visitors between servers.
  6. Check the answer with dig (next section), then configure the VM.

Example A record and CNAME record to copy

This is the result in zone-file format. Most panels show the same fields: name, TTL, type and value. Replace the documentation IPs with your VM's addresses.

; Point example.com to the VM
example.com.      300  IN  A      203.0.113.10
example.com.      300  IN  AAAA   2001:db8::10
www.example.com.  300  IN  CNAME  example.com.

Where to enter the records in your DNS panel

Every DNS panel looks a little different, but the fields are the same. Open the DNS or "zone" settings for your domain and click "Add record". Choose the type (A, AAAA or CNAME), enter the host, paste the value and set the TTL.

For the host field, most panels want @ for the root and just www for the subdomain. Some panels add the domain for you, so typing www.example.com would create www.example.com.example.com. Check the preview before you save.

Once everything works, you can raise the TTL to 3600 seconds or more. Higher values mean fewer lookups. Lower values mean faster changes.

DNS propagation: how long it really takes

"DNS propagation" is a slightly misleading name. Nothing gets pushed around the internet. Resolvers simply cache answers until the record's TTL runs out, then ask again.

  • A brand-new record usually resolves within minutes. No resolver has an old answer cached.
  • A changed record updates once the old TTL expires. That is why lowering the TTL in advance helps.
  • Changed nameservers take longest. The registry's delegation can be cached for up to two days on some extensions. [VERIFY: delegation TTL for .tn]

Check DNS propagation with the dig command

The dig command asks DNS directly and skips your browser's cache. First ask your own nameserver, then ask public resolvers:

dig A example.com +short
dig AAAA example.com +short
dig @1.1.1.1 www.example.com +short
dig @8.8.8.8 example.com +short

When every resolver returns your VM's IP, DNS propagation is complete for those resolvers. The dig command also shows the remaining TTL if you drop +short. On Windows without dig, nslookup example.com 1.1.1.1 gives the same answer. If dig shows the right IP but the browser shows the old site, clear the browser's DNS cache or test in a private window.

Configure the VM to answer for your domain

DNS only sends visitors to the IP. The VM still has to accept the connection and know which site to serve.

Open ports 80 and 443

Allow HTTP and HTTPS in two places: the cloud firewall or security group, and the VM's own firewall. On Ubuntu with UFW:

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

Tell the web server your domain name

With Nginx, list both names in server_name. Save this as /etc/nginx/sites-available/example.com, enable it, then run sudo nginx -t and reload Nginx.

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

Add free HTTPS with Let's Encrypt

Let's Encrypt issues free certificates. Its client, Certbot, checks over port 80 that the domain really points to your VM. So finish DNS first, then run:

sudo certbot --nginx -d example.com -d www.example.com

Certbot edits the Nginx config for you and sets up automatic renewal.

Troubleshooting common problems

When you point a domain to a VM and the site still does not load, the cause usually falls into a handful of patterns. Find the symptom, then check the cause.

SymptomLikely causeFix
dig returns the old IPOld TTL not expired, or you edited the wrong panelRe-check nameservers and wait out the old TTL
Root works, www does notNo record for wwwAdd a CNAME record or A record for www
Works on some networks onlyBroken AAAA recordFix IPv6 on the VM or delete the AAAA record
Connection refused or timed outPort 80/443 blocked or web server stoppedCheck both firewalls and systemctl status nginx
Certbot failsDNS not pointing to the VM yetConfirm with dig, then run Certbot again
Site goes down after a VM restartNo static IP addressReserve a static IP and update the A record

Next steps

To point a domain to a VM, you need one A record, an optional AAAA record, a www record and a correctly configured web server. Check each layer in order: nameservers, records, firewall, web server, HTTPS. Most problems show up at the first layer you skipped.

If you are starting fresh, you can search for a domain and deploy a VM on FelCloud, and see the costs on our pay-as-you-go pricing page. For more guides like this one, browse the FelCloud blog.

Frequently asked questions

How long does it take for a domain to point to a new server?
A new A record usually works within minutes. A changed record updates once the previous TTL expires, and a nameserver change can take up to a day or two.
Can I point a domain to a VM without changing nameservers?
Yes. Keep your current nameservers and just edit the A and AAAA records in that DNS panel. You only need to change nameservers if you want a different company to host your DNS.
Will changing my A record break my email?
No. Email follows MX records, which are separate from A records. But if you move to new nameservers, copy your MX and TXT records to the new DNS host first, or mail will stop arriving.
Can I point several domains to the same VM?
Yes. Give each domain an A record with the same IP, then add a separate server block (Nginx) or virtual host (Apache) for each domain on the VM.
Can a subdomain point to a different VM than the main domain?
Yes. Each name has its own records, so an A record for app.example.com can use a different IP from example.com.
F
FelCloud Team Cloud infrastructure at FelCloud — building pay-as-you-go compute, storage and networking from Carthage, Tunisia.