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 +shortIf 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.
| Record | Maps a name to | Use it for | Example value |
|---|---|---|---|
| A record | An IPv4 address | The root domain and any subdomain | 203.0.113.10 |
| AAAA record | An IPv6 address | The same names, if your VM has IPv6 | 2001:db8::10 |
| CNAME record | Another domain name | Subdomains like www that should follow the root | example.com. |
| MX record | A mail server name | Email only, so leave it alone here | 10 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.
- 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.
- Add an A record for the root. Host
@, value = your VM's IPv4 address. - Add an AAAA record for the root, but only if the VM really answers on IPv6.
- Add www. Use a CNAME record pointing to the root, or a second A record with the same IP.
- 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.
- 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 +shortWhen 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/tcpTell 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.comCertbot 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.
| Symptom | Likely cause | Fix |
|---|---|---|
| dig returns the old IP | Old TTL not expired, or you edited the wrong panel | Re-check nameservers and wait out the old TTL |
| Root works, www does not | No record for www | Add a CNAME record or A record for www |
| Works on some networks only | Broken AAAA record | Fix IPv6 on the VM or delete the AAAA record |
| Connection refused or timed out | Port 80/443 blocked or web server stopped | Check both firewalls and systemctl status nginx |
| Certbot fails | DNS not pointing to the VM yet | Confirm with dig, then run Certbot again |
| Site goes down after a VM restart | No static IP address | Reserve 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.