What Really Happens When You Enter a URL? A Deep Dive into DNS Resolution and Server Setup
This article explains the complete journey of a browser request—from entering a URL, through DNS hierarchy, recursive and iterative queries, to TCP handshakes and HTTP exchange—while also providing step‑by‑step guides for building your own DNS server with BIND or dnsmasq and using dig to trace resolutions.
What Happens When a Browser Requests a URL
The client first ensures network connectivity, then the user types a URL and presses Enter. The browser performs a local DNS lookup to translate the domain name into an IP address, initiates a TCP three‑way handshake, sends an HTTP request, receives the response, renders the page, and finally closes the TCP connection with a four‑way handshake.
0. Ensure internet connectivity
1. Enter URL in browser (e.g., www.yuchaoit.cn)
2. Perform DNS lookup to obtain IP
3. Start TCP three‑way handshake with the server
4. Send HTTP request (may involve multiple requests)
5. Server processes request and sends HTTP response(s)
6. Browser parses and renders the response
7. Close connection (TCP four‑way handshake)DNS Hierarchy and Domain Structure
Domain names are organized in a tree‑like hierarchy. Each label is separated by a dot, forming root (.), top‑level domains (e.g., .cn, .com), second‑level domains (e.g., yuchaoit), and sub‑domains (e.g., www).
Root servers (13 globally) are the authoritative source for top‑level domain information.
# Root zone example (simplified)
. IN NS a.root-servers.net.
. IN NS b.root-servers.net.
... (total 13 root servers)DNS Resolution Process
The resolver follows these steps:
Check the local /etc/hosts file for a static mapping.
If not found, query the configured local DNS server (often provided by the ISP).
The local server checks its cache; if missing, it recursively queries root servers, then TLD servers, then authoritative servers for the domain.
The final IP address is returned to the client and cached for future queries.
Key DNS Terminology
Domain name
DNS resolution
Recursive query
Iterative query
TTL (Time‑to‑Live)
Cache
Using dig to Trace DNS Resolution
Install the utility with yum install bind-utils -y and run:
# Show local DNS servers
cat /etc/resolv.conf
# Trace the full resolution path
dig +trace www.yuchaoit.cn
# Sample output (truncated)
. 2974 IN NS a.root-servers.net.
... (root servers)
cn. 172800 IN NS a.dns.cn.
... (TLD servers)
www.yuchaoit.cn. 600 IN A 123.206.16.61The output demonstrates the query flow from root to TLD to authoritative servers, ending with the final A record.
Setting Up Your Own DNS Server with BIND
Steps (Linux example):
Prepare two machines: a server (e.g., 172.16.1.61) and a client (e.g., 172.16.1.7).
Install BIND: yum install bind bind-utils -y.
Disable firewalls or open port 53.
Edit /etc/named.conf to listen on all interfaces and allow queries.
Create a zone file for your domain (e.g., laoliulinux.cn.zone) and include it in /etc/named.rfc1912.zones.
Define records (A, NS, SOA) in the zone file.
Start the service: systemctl start named and verify with netstat -tunlp | grep named.
Configure clients to use the new DNS server by setting nameserver 172.16.1.61 in /etc/resolv.conf.
# Example zone file (laoliulinux.cn.zone)
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS @
IN A 172.16.1.61
www IN A 172.16.1.61
linux IN A 172.16.1.61Deploying a Lightweight DNS Server with dnsmasq
dnsmasq provides a simple alternative to BIND.
Install: yum install dnsmasq -y.
Create /etc/dnsmasq.conf and set upstream DNS, listen address, and additional hosts file.
Prepare /etc/resolv.dnsmasq.conf (upstream) and /etc/hosts.dnsmasq.conf (local mappings).
Start the service: systemctl start dnsmasq.
Point client /etc/resolv.conf to the dnsmasq server (e.g., nameserver 172.16.1.61).
# /etc/dnsmasq.conf (relevant lines)
resolv-file=/etc/resolv.dnsmasq.conf
listen-address=172.16.1.61
addn-hosts=/etc/hosts.dnsmasq.conf
# Example hosts file
172.16.1.61 master-61
172.16.1.7 web-7
... (other internal hosts)Both BIND and dnsmasq can be used to resolve internal domain names, provide caching, and support custom A records for services within a private network.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
