Skip to main content

Command Palette

Search for a command to run...

DNS resolution : how it works as a resolver and serve the web page

Updated
4 min read
DNS resolution : how it works as a resolver and serve the web page

DNS or Domain name system works as a phonebook. So whenever any user type the name google.com in the browser, it automatically lookup the associated IP and display the required content from that server. This entire lookup system is moreover known as a Domain Name System aka DNS.

How DNS works?

DNS works like a telephone directory, where it stores all the associated IP with the human readable domain name. So whenever you have entered any domain name or my personal website in the browser like somnathsahu.dev it goes to the DNS resolver which is your ISP.

Now this resolver looks for the name server for the IP and this root server directs it to the Top-Level Domain (TLD) server (e.g., for .dev).

The resolver asks the TLD server, which points it to the Authoritative Nameserver for somnathsahu.dev. The Authoritative Nameserver holds the actual IP address and sends it back to the resolver. And the resolver sends the IP address to your browser.

Now your browser uses the IP address to connect to the website's server and display the website content.

DIG Command and DNS resolution

DIG command is a powerful administrative tool that helps to query DNS name servers for troubleshooting, diagnostic, and educational purposes. It is available by default on Linux and macOS, often used to look up A, MX, or CNAME records directly from specific DNS servers.

Basic syntax of DIG command is

dig [server] [name] [type]

  1. [server] it is an optional parameter for IP address or hostname of the DNS server to query.

  2. [name] it helps to query a domain name. This is the DNS resource record about which you want information.

  3. [type] it is an optional parameter. DNS record type to query, including A, MX, and NS. dig will query an A record if no type is specified by default.

For example, to execute an A record for below example

dig example.com it will return below response

; <<>> DiG 9.16.1-Ubuntu <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12345
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1
;; QUESTION SECTION:
;example.com.   IN  A
;; ANSWER SECTION:
example.com.  3600  IN  A 93.184.216.34
;; AUTHORITY SECTION:
example.com.  3600  IN  NS ns1.example.com.
example.com.  3600  IN  NS ns2.example.com.
;; ADDITIONAL SECTION:
ns1.example.com.  3600  IN  A 192.0.2.1
;; Query time: 10 msec
;; SERVER: 192.0.2.53#53(192.0.2.53)
;; WHEN: Sun Jan 25 14:00:00 UTC 2026
;; MSG SIZE  rcvd: 123

Some important DIG command

MX record

MX record returns mail exchange server details to send/receive emails. To troubleshoot this email records execute below command

dig example.com MX

...
;; QUESTION SECTION:
;example.com.  IN  MX
;; ANSWER SECTION:
example.com.  3600  IN  MX 10 mail.example.com.
;; ADDITIONAL SECTION:
mail.example.com.  3600  IN  A 192.0.2.2
...

NS record

The name server (NS) record lists the name servers responsible for the domain. It helps to understand the domain’s DNS infrastructure.

dig example.com NS

...
;; QUESTION SECTION:
;example.com.  IN  NS
;; ANSWER SECTION:
example.com.  3600  IN  NS ns1.example.com.
example.com.  3600  3600  IN  NS ns2.example.com.
;; ADDITIONAL SECTION:
ns1.example.com.  3600  IN  A 192.0.2.1
...

SOA record

The start of authority (SOA) record contains administrative information about the domain, including the primary name server and the domain administrator’s registered email.

dig example.com SOA

...
;; QUESTION SECTION:
;example.com.  IN  SOA
;; ANSWER SECTION:
example.com.  3600  IN  SOA ns1.example.com. hostmaster.example.com. 2021071601 3600 1800 1209600 300
...

Tracing the DNS path

Tracing the DNS path involves following a DNS query from your computer to the authoritative name server. This process lets you see the route queries take to the final DNS server.

To trace the DNS path, append the +trace option to your command like this:

dig example.com +trace

The dig output shows the DNS servers involved at each step:

.                       518400  IN      NS      a.root-servers.net.
.                       518400  IN      NS      b.root-servers.net.
;; Received 512 bytes from 192.0.2.1 #53(192.0.2.1) in 5 ms
example.com.            3600    IN      NS      ns1.example.com.
example.com.            3600    IN      NS      ns2.example.com.
;; Received 200 bytes from 192.0.2.1#53(192.0.2.1) in 10 ms
example.com.            3600    IN      A       93.184.216.34
;; Received 100 bytes from 192.0.2.2#53(192.0.2.2) in 15 ms

Final words

In this article, I’ve covered the essential uses of the Linux dig command, from fundamental DNS lookups to more advanced queries and troubleshooting methods. In addition, mastering dig can enhance your network management skills

More from this blog

S

Somnath Sahu

14 posts

DNS resolution : how it works as a resolver and serve the web page