Skip to content
Technology Hub

DNS Domain Name Service: How It Works and How to Check It

Learn how DNS connects domain names to websites and email, which DNS records matter, and how to check them from Ubuntu 24.04. Use practical `dig` commands to troubleshoot common DNS problems safely.

Ritik Barnwal 16 min read 1 views

DNS (Domain Name System) is the service that helps a browser find the server behind a domain name. Without it, visitors would have to type numerical IP addresses instead of names such as example.com. Knowing how DNS works makes it easier to launch a site, change hosting providers and troubleshoot access or email problems.

Tested on Ubuntu 24.04 LTS — November 2026

Prerequisites

You need:

  • Ubuntu 24.04 LTS with a non-root user that can use sudo.

  • Outbound UDP and TCP port 53 access. If your network blocks DNS, the checks below will fail even when the domain is configured correctly.

  • A registered domain, plus access to the registrar and authoritative DNS provider accounts.

  • The bind9-dnsutils package for dig, and curl for optional HTTP checks. On Ubuntu 24.04, dnsutils is a transitional package, so install bind9-dnsutils directly.

source /etc/os-release
printf '%s\n' "$PRETTY_NAME"
sudo -v
sudo apt update
sudo apt install -y bind9-dnsutils curl
dig -v
curl --version | head -n 1

Expected output is similar to:

Ubuntu 24.04.x LTS
DiG 9.18.x-...
curl 8.x.x ...

Replace your_domain with your registered domain name. Leave out https://, and usually leave out the trailing dot that some provider control panels add. Replace YOUR_SERVER_IP, YOUR_SERVER_IPV6 and YOUR_MAIL_SERVER_IP with the addresses your hosting or email provider gives you.

DNS domain name service: what it is and how it works

DNS stands for Domain Name System. It is sometimes called the domain name service because its job is to look up domain names and return the information needed to reach them. The terms "domain name service DNS" and "domain name service" refer to the same process: turning a domain name into network information, usually an IP address.

Think of DNS as an internet directory. People use memorable names, and computers use IP addresses to route traffic. DNS connects the two. It also stores other details about a domain, such as which servers receive its email.

DNS is a distributed, hierarchical database with two main roles:

  • Recursive resolver: receives a query from a client, follows referrals through the DNS hierarchy, caches answers and returns the result. Your ISP, a public resolver such as Cloudflare or Google, or your own infrastructure may run one.

  • Authoritative DNS server: holds the actual records for a zone and answers for that zone. The domain owner or DNS administrator manages these records on the authoritative DNS service.

A typical lookup goes like this:

  1. You enter a domain name in your browser.

  2. The browser or operating system (the stub resolver) checks whether it already has a usable cached answer.

  3. If it does not, a recursive resolver, often run by your internet service provider or a public DNS provider, looks up the answer.

  4. The resolver follows the DNS hierarchy. It asks a root server where to find the top-level domain, such as .com or .in. Then it asks that top-level domain's servers for the domain's authoritative nameservers.

  5. The authoritative DNS server returns the record you asked for. The resolver caches the answer for a set time and sends it to your device.

The TTL, measured in seconds, controls how long a record stays cached. Negative answers, such as "this name does not exist," can also be cached, based on the zone's SOA negative-caching value. DNS normally uses UDP port 53. TCP port 53 handles larger responses, zone transfers and some fallback cases. DNSSEC adds signatures for integrity and origin authentication, but it does not encrypt queries. DNS over TLS and DNS over HTTPS encrypt traffic between a client and a resolver. They do not replace correct authoritative records or DNSSEC validation.

The registrar manages your domain registration, and you usually set the domain's nameservers there. Domain registration and web hosting are related but separate services. For more on the difference, see the difference between domain hosting and web hosting.

DNS records you should know

DNS records are the instructions stored for a domain. The records you need depend on the services you use. These are the most common:

RecordPurposeAPoints a name, such as example.com, to an IPv4 address.AAAAPoints a name to an IPv6 address.CNAMEMakes one hostname an alias for another, often used for www. It generally cannot be used at the zone apex, such as example.com. Some DNS providers offer alternatives such as ALIAS or ANAME records. A CNAME also cannot share a name with other records.MXLists the mail servers that receive email for the domain. Lower priority values are preferred.TXTStores text for purposes such as domain verification and email authentication policies, including SPF, DKIM and DMARC.NSIdentifies the authoritative nameservers for a domain or delegated subdomain.CAASpecifies which certificate authorities may issue TLS certificates for the domain.SOAStart of Authority record. It holds the primary nameserver, administrator contact, serial number, refresh, retry and expire timers, and the negative-caching TTL.

A record change can affect just one service or hostname. For example, changing the website's A record does not update the MX records. Keep this in mind when you move a website but keep email with its current provider.

The zone-file example below shows the record types. It is not a complete BIND configuration. Provider web interfaces usually ask for the same values without the $ORIGIN and $TTL directives.

$ORIGIN your_domain.
$TTL 3600

@   IN  SOA ns1.your_dns_provider.example. hostmaster.your_domain. (
        2026110101 ; serial: increase on every change
        3600       ; refresh
        900        ; retry
        1209600    ; expire
        300        ; negative caching TTL
)

@       IN  NS      ns1.your_dns_provider.example.
@       IN  NS      ns2.your_dns_provider.example.

@       IN  A       YOUR_SERVER_IP
@       IN  AAAA    YOUR_SERVER_IPV6
www     IN  CNAME   your_domain.

@       IN  MX      10 mail.your_domain.
mail    IN  A       YOUR_MAIL_SERVER_IP

@       IN  TXT     "v=spf1 mx -all"
_dmarc  IN  TXT     "v=DMARC1; p=quarantine; rua=mailto:dmarc@your_domain"

@       IN  CAA     0 issue "letsencrypt.org"

To check a BIND zone file on Ubuntu 24.04 before you reload BIND, run:

sudo apt install -y bind9-utils
sudo named-checkzone your_domain /etc/bind/db.your_domain

Expected output is similar to:

zone your_domain/IN: loaded serial 2026110101
OK

Leave out the AAAA record if the service has no IPv6 address. Never point an MX record at a CNAME. Use an A or AAAA record for the mail hostname instead.

How DNS affects website performance and availability

DNS is the first step after you enter a URL. If a lookup is slow, the browser waits longer before it can connect to the web server. A cached answer skips a fresh lookup. A reliable authoritative DNS service makes sure new lookups get an answer.

DNS is only one part of performance. It cannot speed up a slow application or an overloaded server, and a fast lookup cannot make up for large images or inefficient code. A content delivery network (CDN) may use DNS to send visitors to a nearby edge location. The CDN's caching and delivery do the real work of serving content efficiently, not DNS alone.

Availability matters too. If the authoritative DNS service is unreachable, visitors may not resolve your domain once their cached answers expire, even if the web server is running. Use at least two authoritative nameservers. Ideally, put them on separate infrastructure or with a provider that offers redundant anycast service. Multiple A records can spread traffic, but they do not provide health-checked failover by themselves. Keep your domain registration and DNS accounts secure, and know which provider hosts your authoritative records.

Practical DNS checks with dig

The dig tool queries DNS records from the terminal. On Ubuntu 24.04, install it with the bind9-dnsutils package if it is missing. When you check a live site, replace example.com with your own domain.

sudo apt update
sudo apt install -y bind9-dnsutils
dig -v

Expected output is similar to:

DiG 9.18.x-...

To compare the answer from a public resolver with the answer from your default resolver, query both:

dig your_domain A
dig your_domain AAAA
dig your_domain MX
dig @1.1.1.1 your_domain A

The full response has a header, a question section and an answer section. Check the status: line and the ANSWER SECTION. A successful answer looks similar to:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12345
;; ANSWER SECTION:
your_domain.        3600    IN    A    YOUR_SERVER_IP

For shorter output, add +short:

dig +short A your_domain
dig +short AAAA your_domain
dig +short MX your_domain
dig +short NS your_domain
dig +short TXT your_domain
dig +short CAA your_domain

Expected output is similar to:

YOUR_SERVER_IP
YOUR_SERVER_IPV6
10 mail.your_domain.
ns1.your_dns_provider.example.
ns2.your_dns_provider.example.
"v=spf1 mx -all"
0 issue "letsencrypt.org"

An empty +short result often means the record type is not configured. It does not necessarily mean DNS is broken. Run the full query to see the status. NOERROR with no answer is NODATA, which means the name exists but has no record of that type. NXDOMAIN means the name does not exist.

To see the delegation path from the DNS root down to the domain's authoritative servers, run a trace:

dig +trace your_domain

The output shows referrals from the root servers, the top-level domain delegation, the domain's NS records and finally the answer from an authoritative server. Some networks block direct queries to root servers. On those networks, +trace can fail even when normal resolution works.

To check the local resolver on Ubuntu 24.04, run:

resolvectl status
resolvectl query your_domain

The output lists the active DNS servers for each network link and a resolved answer, similar to this:

your_domain: YOUR_SERVER_IP

Ubuntu 24.04 uses systemd-resolved. /etc/resolv.conf is usually a symlink that systemd manages, so don't edit it directly to make a lasting change:

ls -l /etc/resolv.conf

Expected output is similar to:

lrwxrwxrwx 1 root root ... /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

To clear only the local systemd-resolved cache, run:

sudo resolvectl flush-caches
resolvectl query your_domain

This does not flush public resolvers or other machines. To query an authoritative server directly, get the NS records first. Then ask one of those servers without recursion:

dig +short NS your_domain
dig @ns1.your_dns_provider.example your_domain A +norecurse

The output is the NS list, followed by an authoritative A answer. If the server returns REFUSED or no answer, confirm that it is authoritative for the zone and that your source address is allowed to query it.

To check DNSSEC status, run:

dig +short DS your_domain
dig +dnssec your_domain A

A signed zone normally has a DS record at the parent and RRSIG records in DNSSEC-aware responses. If the DS record is missing, the parent zone is not signed, even if your provider offers DNSSEC.

Read the ANSWER SECTION for the returned records. The TTL value shows how much cache time remains. A missing answer is not always an error, since the record type may simply not be set up. When results differ between resolvers, cached data or a delegation problem may be the cause. Wait out the TTL and check the authoritative server before you assume a change failed.

How to optimize DNS settings safely

Follow these steps when you set up a domain or prepare a DNS change. The labels in your registrar or DNS provider's control panel may differ from the ones here.

  1. Find the authoritative DNS provider. Check the nameservers listed in your registrar account. You manage records at the provider those nameservers point to, which may not be the company where you bought the domain.

dig +short NS your_domain


   Expected output lists the nameservers, for example:

   ```text
ns1.your_dns_provider.example.
ns2.your_dns_provider.example.
  1. Save the current zone before you change anything. Export the existing records, especially the MX and TXT records used for email, verification and security policies. Before you switch nameservers, recreate the required records at the new DNS provider. Otherwise, your website, email or other services may stop resolving.

for type in A AAAA MX TXT NS CAA SOA; do printf '== %s ==\n' "$type" dig +noall +answer your_domain "$type" done | tee "dns-backup-$(date +%F).txt"


   Expected output is a text file with the current answers and TTLs. If your provider supports a full zone export, save that too. A zone transfer can also export the records, but most providers restrict it:

   ```bash
dig AXFR your_domain @ns1.your_dns_provider.example

Warning

Do not enable public zone transfers just to make AXFR work. A zone transfer exposes every record in the zone, so allow it only for authorized addresses. Do not delete or replace old records until the new ones are verified and the old TTL has expired.

  1. Add only the records your services need. Set the web records your hosting provider gives you, and keep your existing email records if email is hosted elsewhere. Remove duplicate or outdated records that could send visitors or mail to the wrong place. If you are starting from scratch, you can register a domain with TextraHost and set up its DNS for the services you choose.

    After you add records, verify the types you changed:

dig +short A your_domain dig +short AAAA your_domain dig +short MX your_domain dig +short TXT your_domain


   The output should match the values from your hosting or email provider. If you use a BIND zone file, run `named-checkzone` before you reload BIND.

4. **Pick TTL values to fit your change schedule.** The TTL sets how long resolvers may cache a record. A shorter TTL makes planned changes visible sooner after cached data expires, but it also means more frequent lookups. For stable records, use a sensible value your DNS provider supports. Don't set every record as low as possible. Before a planned migration, lower the TTL, make the change, verify it, and then raise the TTL again if needed.

   Check the current TTL with:

   ```bash
dig +noall +answer your_domain A

Expected output is similar to:

your_domain.        3600    IN    A    YOUR_SERVER_IP

The second field is the remaining TTL in seconds. Very low TTLs increase query volume, and they do not guarantee that changes appear everywhere right away.

  1. Check the result from more than one resolver. Query the record type you changed, compare the results with the authoritative answer, and test the live website or email service. DNS changes do not reach every resolver at the same moment. Resolvers keep using cached answers until the TTL expires. People often call this propagation, but it usually means caches refreshing, not one global update.

dig @1.1.1.1 your_domain A +short dig @8.8.8.8 your_domain A +short dig @9.9.9.9 your_domain A +short dig @ns1.your_dns_provider.example your_domain A +short +norecurse


   Expected output is the same address from each resolver once their caches refresh. If the authoritative answer is correct but a public resolver still returns the old address, check the remaining TTL and wait.

6. **Secure access to DNS and your domain account.** Use unique passwords and multi-factor authentication where available. Give account access only to people who need it, and turn on a registrar lock if it suits your setup. Ask your provider about DNSSEC. It helps resolvers confirm that DNS data has not been altered, but a wrong DNSSEC setup can stop a domain from resolving. Don't enable it until you understand how the keys and delegation records are managed.

   ```bash
dig +short DS your_domain
dig +dnssec your_domain A | grep -E 'status:|RRSIG'

For a correctly signed zone, the output shows a DS record and RRSIG data. Warning: Do not turn off DNSSEC validation globally, and do not remove DS records as a permanent fix for a signing mistake. Repair the DS, DNSKEY and RRSIG chain, or roll back the DNSSEC change on purpose.

Common DNS troubleshooting mistakes

A site that breaks after a hosting move may have an old A record, wrong nameservers or a missing record in the new authoritative zone. Check the nameservers first. Then query the record at the authoritative provider.

dig +short NS your_domain
dig @ns1.your_dns_provider.example your_domain A +norecurse

Expected output is the current NS list and an authoritative A answer. If only www fails, or only the root domain fails, compare the two records separately. They may be configured differently.

dig +short A your_domain
dig +short A www.your_domain
dig +short CNAME www.your_domain

Email problems after a DNS change often come from missing or wrong MX records, or from TXT records used for email authentication. Restore the values your email provider gives you rather than guessing.

dig +short MX your_domain
dig +short TXT your_domain
dig +short TXT _dmarc.your_domain

A lookup that returns an old IP address does not always mean the record was saved wrong. Check the TTL, and compare the authoritative answer with the response from a cached resolver.

dig +noall +answer your_domain A
dig @1.1.1.1 +noall +answer your_domain A
dig @ns1.your_dns_provider.example +noall +answer your_domain A +norecurse

The output may show different remaining TTLs. The authoritative server returns the configured TTL. A resolver returns the TTL that remains in its cache.

If you are setting up a site for the first time, confirm that the hosting account is ready to serve the domain. DNS pointing to the right destination is not enough on its own.

curl -I "https://your_domain"

Expected output is an HTTP status line, such as HTTP/2 200, or a redirect. A Could not resolve host error points to DNS. A connection refused or timeout error points to the web server, the firewall or the hosting configuration. Hosting and DNS each cover a different part of availability. This guide to choosing a secure and affordable hosting provider explains what to check on the hosting side.

Troubleshooting

dig: command not found: The DNS utilities are not installed.

sudo apt update
sudo apt install -y bind9-dnsutils
dig -v

Expected output is a DiG version line.

;; communications error to 127.0.0.53#53: timed out: The local systemd-resolved stub is not responding.

systemctl status systemd-resolved --no-pager
resolvectl status
sudo systemctl restart systemd-resolved

The expected status is Active: active (running). Restarting systemd-resolved briefly interrupts local name resolution. If the problem continues, check your firewall rules and confirm that /etc/resolv.conf still points to the systemd-resolved stub.

status: NXDOMAIN: The name does not exist in the zone, or your query used the wrong name.

dig +short NS your_domain
dig @ns1.your_dns_provider.example your_domain A +norecurse

If the authoritative server has the record but a public resolver returns NXDOMAIN, wait out the negative-cache TTL or check the delegation.

status: SERVFAIL: The resolver could not finish the lookup. Common causes are a DNSSEC validation failure, an authoritative server failure or an upstream problem.

dig +cd your_domain A
dig +trace your_domain
dig +dnssec your_domain A

If +cd works but normal queries fail, look into DNSSEC. Do not turn off DNSSEC validation permanently as a workaround.

status: REFUSED: The server is not authoritative for the name, or it refuses recursion.

dig +short NS your_domain
dig @ns1.your_dns_provider.example your_domain A +norecurse

If you run BIND, do not enable open recursion. Limit queries and recursion to trusted clients.

connection timed out; no servers could be reached: Outbound DNS is blocked, or the resolver is down.

dig @1.1.1.1 your_domain A
dig +tcp @1.1.1.1 your_domain A

If the public resolver works, fix the local resolver. If it does not, check your network and firewall rules. Warning: Do not open inbound UDP or TCP port 53 on a general-purpose server unless it is meant to run an authoritative DNS server. If you do open it, restrict access to trusted networks and disable open recursion.

named-checkzone reports CNAME and other data: A CNAME shares a name with another record, often at the zone apex.

sudo named-checkzone your_domain /etc/bind/db.your_domain

Use A or AAAA records, or an ALIAS or ANAME feature, at the apex. Use CNAME only for names below the apex.

dig +short prints nothing: The record type may not exist, or the name may not exist.

dig your_domain A

Check the status: line and the ANSWER SECTION. NOERROR with no answer is NODATA. NXDOMAIN means the name does not exist.

Conclusion

DNS connects a memorable domain name to the services behind it. Careful record management, sensible caching and secure account access keep those services reachable. If you also need hosting along with domain and DNS setup, TextraHost offers hosting from data centres in India and Singapore.

Frequently asked questions

What is the DNS domain name service?

DNS stands for Domain Name System and looks up domain names to return the information needed to reach them, usually an IP address. It also stores other details for a domain, such as which servers receive its email.

How do I install dig on Ubuntu 24.04?

On Ubuntu 24.04, install dig with the bind9-dnsutils package: sudo apt update followed by sudo apt install -y bind9-dnsutils. Check the installation with dig -v.

How do I check A and MX records with dig?

Run dig your_domain A to query the A record and dig your_domain MX to query the MX record. Replace your_domain with your registered domain name.

How do I flush the DNS cache on Ubuntu 24.04?

To clear only the local systemd-resolved cache, run sudo resolvectl flush-caches and then resolvectl query your_domain. This does not flush public resolvers or other machines.

What does NXDOMAIN mean in a DNS lookup?

NXDOMAIN means the name does not exist. It can mean the name does not exist in the zone or that the query used the wrong name.

Comments

Loading comments…

Leave a comment

Keep reading

Newsletter

Get new guides in your inbox

Practical tutorials from the TextraHost team. No spam, unsubscribe anytime.