Q: What is DNS (Domain Name System) and how does it work?
A: DNS is a distributed naming system that maps human-friendly domain names to computer-readable IP addresses. It routes user requests to the correct servers.
How DNS works:
- The user enters a domain name (e.g., www.example.com) into their browser.
- The operating system queries its local DNS server.
- If the local DNS server has the IP address in its cache, it returns it.
- If not, the local DNS server queries a root DNS server.
- The root server directs the local server to the top-level domain (TLD) server responsible for the
.comdomain. - The local server then queries the
.comTLD server. - The
.comTLD server directs the local server to the authoritative DNS server forexample.com. - The local server queries the authoritative DNS server for
www.example.com's IP address. - The authoritative server returns the IP address, which the local server caches and returns to the operating system.
- The operating system uses the IP address to connect to the server and fetch the requested resource.