Mastering DNS: How Domain Names Turn Into IP Addresses
This article explains the fundamentals of the Domain Name System, walks through the multi‑step DNS query process using tools like dig, describes the hierarchy of name servers from root to host, and introduces common DNS record types and auxiliary utilities for troubleshooting and analysis.
DNS is one of the core Internet protocols; understanding it is essential for browsing and development.
1. What is DNS?
DNS (Domain Name System) simply maps domain names to IP addresses, acting like a massive phone book. For example, the domain
math.stackexchange.comresolves to the IP address
151.101.129.69.
2. Query Process
Although the result is a single IP address, the DNS lookup involves several steps. The
digtool can display the entire process.
<code>$ dig math.stackexchange.com</code>The command output consists of six sections:
1) Query parameters and statistics.
2) Query content (the A record request).
3) DNS server response.
4) Four A records for the domain and the TTL value (600 seconds).
5) The IP addresses of the four authoritative name servers.
6) Transmission details, including the local DNS server (e.g.,
192.168.1.253) and response length.
Using the
+shortoption simplifies the output:
<code>$ dig +short math.stackexchange.com
151.101.129.69
151.101.65.69
151.101.193.69
151.101.1.69</code>3. DNS Servers
The local machine must know the IP address of a DNS server, which can be assigned via DHCP or configured statically in
/etc/resolv.conf. Common public DNS servers include Google’s
8.8.8.8and Level 3’s
4.2.2.2. Queries can be directed to a specific server with the
@flag:
<code>$ dig @4.2.2.2 math.stackexchange.com</code>4. Domain Hierarchy
DNS uses a hierarchical naming scheme:
host.sld.tld.root. The trailing dot represents the root zone, which is implicit in everyday use. The hierarchy consists of the root zone, top‑level domains (TLDs) like
.com, second‑level domains (SLDs) such as
example, and the host name.
<code>host.sld.tld.root</code>5. Root Name Servers
Root servers store the NS records for the root zone. An example list includes A.ROOT‑SERVERS.NET (198.41.0.4), B.ROOT‑SERVERS.NET (192.228.79.201), and C.ROOT‑SERVERS.NET (192.33.4.12). There are thirteen root server groups in total.
6. Hierarchical Query Example
The
dig +tracecommand shows the full iterative resolution process.
<code>$ dig +trace math.stackexchange.com</code>The first section lists all root server NS records. Subsequent sections query the TLD servers, then the second‑level servers, and finally the authoritative server that returns the A records.
7. NS Record Queries
Specific NS records can be retrieved with:
<code>$ dig ns com
$ dig ns stackexchange.com</code>Adding
+shortsimplifies the output.
<code>$ dig +short ns com
$ dig +short ns stackexchange.com</code>8. DNS Record Types
Common record types include:
A – address record (IP address).
NS – name server record.
MX – mail exchange record.
CNAME – canonical name (alias).
PTR – pointer record for reverse lookups.
Redundancy is achieved by having multiple NS, A, or MX records.
9. Other DNS Tools
host – a simplified version of
digthat returns all records for a domain.
<code>$ host github.com</code>nslookup – interactive query tool.
<code>$ nslookup
> facebook.github.io</code>whois – shows domain registration information.
<code>$ whois github.com</code>10. References
DNS: The Good Parts, by Pete Keen
DNS 101, by Mark McDonnell
Efficient Ops
This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.