Fundamentals 15 min read

Mastering DNS: From Basics to Advanced Queries

This article explains the fundamentals of the Domain Name System, how DNS queries work, the role of DNS servers, hierarchical name resolution, record types, and useful command‑line tools such as dig, host, and nslookup, providing clear examples and diagrams for each concept.

Efficient Ops
Efficient Ops
Efficient Ops
Mastering DNS: From Basics to Advanced Queries

DNS (Domain Name System) is one of the core Internet protocols; understanding it is essential for both browsing and development.

1. What is DNS?

DNS translates domain names into IP addresses, acting like a massive phone book. For example, the domain math.stackexchange.com resolves to the IP 151.101.129.69.

2. Query Process

The lookup involves several steps, which can be displayed with the dig tool. $ dig math.stackexchange.com The command returns six sections:

Query parameters and statistics.

Query content.

DNS server response.

NS records for stackexchange.com.

IP addresses of the name servers.

Transmission information.

Adding +short simplifies the output to the four A records for the domain.

$ dig +short math.stackexchange.com
151.101.129.69
151.101.65.69
151.101.193.69
151.101.1.69

3. DNS Servers

The local machine must know a DNS server’s IP (often provided via DHCP or configured in /etc/resolv.conf). Example server IP: 192.168.1.253. Public servers include Google’s 8.8.8.8 and Level 3’s 4.2.2.2.

$ dig @4.2.2.2 math.stackexchange.com

4. Domain Hierarchy

Domain names are hierarchical: host.sld.tld.root. The trailing dot represents the root zone. Example: www.example.com. The levels are root → top‑level domain (TLD) → second‑level domain (SLD) → host.

host.sld.tld.root

5. Root Name Servers

Root servers (A‑ROOT‑SERVERS.NET, B‑ROOT‑SERVERS.NET, …) have fixed IPs such as 198.41.0.4. There are thirteen root server groups worldwide.

6. Hierarchical Query Example

Using dig +trace shows the full resolution chain from root to authoritative server.

$ dig +trace math.stackexchange.com

7. NS Record Queries

Specific NS records can be queried with dig ns com or dig ns stackexchange.com, optionally using +short for concise output.

$ dig ns com
$ dig ns stackexchange.com

8. DNS Record Types

Common record types:

A : address record, returns an IP address.

NS : name‑server record, points to the server for the next zone.

MX : mail exchange record, specifies mail servers.

CNAME : canonical name, an alias to another domain.

PTR : pointer record, used for reverse lookups.

Example CNAME lookup:

$ dig facebook.github.io
;; ANSWER SECTION:
facebook.github.io. 3370 IN CNAME github.map.fastly.net.

Reverse lookup example:

$ dig -x 192.30.252.153
;; ANSWER SECTION:
153.252.30.192.in-addr.arpa. 3600 IN PTR pages.github.com.

9. Other DNS Tools

host provides a simplified view of records. $ host github.com nslookup offers an interactive query interface.

$ nslookup
> facebook.github.io

whois shows domain registration information.

$ whois github.com

10. References

DNS: The Good Parts, Pete Keen

DNS 101, Mark McDonnell

Appendix – DNS Overview

DNS maps hostnames to IP addresses over UDP port 53. It can be static (local hosts file) or dynamic (central DNS servers). Proper configuration prevents security issues such as DDoS, hijacking, and information leakage.

Common security concerns include malicious attacks on DNS infrastructure, domain hijacking, vulnerable DNS software, and misconfigurations that expose sensitive data.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

network troubleshootingNetworkingDNSDomain Name SystemdigDNS Records
Efficient Ops
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.