Networking

What Is DNS? How Domain Names Turn Into Server Addresses

By NileVPS Team · Published · 5 min read

اقرأ المقال بالعربي

Every time someone types your domain into a browser, a quiet lookup happens before a single byte of your website loads. The Domain Name System (DNS) translates human-friendly names such as example.com into the numeric IP addresses that computers actually use to reach each other. If you run a website, an API or a mail server on a VPS, understanding DNS saves you hours of confusion when a new site "does not work yet" or when email lands in spam. This guide explains how a lookup travels, which records matter, and how to troubleshoot problems from the command line.

Why DNS exists

Servers on the internet are reached by IP address, for example 203.0.113.10 or an IPv6 address like 2001:db8::10. Numbers are hard to remember and they change when you move to a new server. DNS adds a layer of names on top, so you can change the server behind a name without telling every visitor. If you want a refresher on the addresses themselves, read our guide on IP addresses.

DNS is hierarchical and distributed. No single machine knows every name. Instead, responsibility is delegated from the root of the tree down to the servers that hold the final answer for each domain.

How a DNS lookup works, step by step

When your browser needs the address of www.example.com, the process usually looks like this:

  1. Local cache. The operating system and browser first check whether they already know the answer from a recent lookup.
  2. Recursive resolver. If not, the query goes to a recursive resolver, typically run by your ISP, your company, or a public service. This resolver does the hard work on your behalf.
  3. Root servers. The resolver asks a root server, which does not know the answer but replies with the servers responsible for .com.
  4. TLD servers. The .com servers reply with the authoritative name servers for example.com, as configured at the domain registrar.
  5. Authoritative server. The authoritative server returns the actual record, such as the A record holding the IPv4 address.
  6. Caching. The resolver caches the answer for as long as the record's TTL allows and passes it back to your device.

All of this normally completes in tens of milliseconds, and most queries are answered straight from cache.

The DNS records you will actually use

RecordPurposeExample value
AMaps a name to an IPv4 address203.0.113.10
AAAAMaps a name to an IPv6 address2001:db8::10
CNAMEMakes one name an alias of anotherwww pointing to example.com
MXTells other servers where to deliver email10 mail.example.com
TXTFree text, used for SPF, DKIM, DMARC and domain verificationv=spf1 mx -all
NSLists the authoritative name servers for a zonens1.dnsprovider.net
CAARestricts which certificate authorities may issue certificates0 issue "letsencrypt.org"
PTRReverse lookup from IP to name, set by the IP ownermail.example.com

A CNAME cannot sit at the apex of a domain (the bare example.com) alongside other records, which is why the root name usually uses an A or AAAA record directly.

TTL and "DNS propagation"

Each record carries a Time To Live in seconds. A TTL of 3600 means resolvers may cache the answer for one hour. What people call propagation is really caches expiring at different times around the world.

Practical tips:

  • Lower the TTL to 300 a day before a planned server migration, then raise it again once the move is done.
  • Remember that changing name servers at the registrar involves the parent TLD zone, whose own TTLs are often long, so allow more time.
  • Negative answers (a name that does not exist) are also cached, so create records before you test them, not after.

Pointing a domain to your VPS

Once your server is running, the minimal setup is:

  1. Find your server's public IPv4 and IPv6 addresses in your control panel.
  2. At your DNS provider, create an A record for @ with the IPv4 address and an AAAA record with the IPv6 address.
  3. Create www as a CNAME to the root name, or as separate A and AAAA records.
  4. Wait for the TTL to pass, then verify with the tools below before requesting a TLS certificate.

If you do not have a server yet, you can deploy a VPS and point your domain at it within minutes.

Troubleshooting DNS from the command line

The dig tool (package dnsutils on Debian and Ubuntu, bind-utils on RHEL family systems) is the most useful helper:

# Ask your default resolver for the A record
dig example.com A +short

# Ask a specific public resolver
dig @1.1.1.1 example.com AAAA +short

# Follow the full delegation path from the root
dig example.com +trace

# Check mail and text records
dig example.com MX +short
dig example.com TXT +short

# Reverse lookup of an IP
dig -x 203.0.113.10 +short

On Windows, nslookup example.com and Resolve-DnsName example.com in PowerShell do the same job. On a Linux server that uses systemd-resolved, resolvectl query example.com shows which upstream resolver answered, and resolvectl flush-caches clears the local cache.

Common problems checklist

  • Old IP still showing: the previous TTL has not expired, or you are hitting a local cache.
  • Works with `+trace` but not normally: the resolver has a stale cached answer.
  • NXDOMAIN after changing name servers: the new provider's zone does not contain the record yet.
  • Certificate request fails: an AAAA record points to an address where the web server is not listening.
  • Email rejected: missing or wrong SPF, DKIM, DMARC, or no matching PTR record for the sending IP.

FAQ

How long does a DNS change take to work?

A record change is visible to a given resolver as soon as its cached copy expires, so the old TTL is the realistic upper bound. Name server changes at the registrar can take longer because the TLD zone's records have their own, often longer, TTLs.

Should I run my own DNS server on a VPS?

Usually not for public authoritative DNS. A dedicated DNS provider gives you multiple geographically spread name servers, which is hard to match with one machine. Running a local caching resolver on the VPS, however, can speed up outgoing lookups for busy applications.

What is the difference between a registrar and a DNS provider?

The registrar is where you buy and renew the domain and where you set which name servers are authoritative. The DNS provider hosts the zone with your records. They can be the same company or two different ones.

Related guides