dns - dwilson2547/wiki_demo GitHub Wiki

DNS: Domain Name System


1. Overview

The Domain Name System (DNS) is a hierarchical, decentralized naming system that translates human-readable domain names (e.g., example.com) into machine-readable IP addresses (e.g., 192.0.2.1). It is a critical component of the internet, enabling users to access websites and services without memorizing numeric IP addresses.


2. How DNS Works

Core Function

  • Resolution: Converts domain names to IP addresses (and vice versa).
  • Hierarchy: Organized in a tree-like structure with multiple levels:
    • Root DNS Servers: Direct queries to top-level domains (TLDs).
    • TLD Servers: Manage domains like .com, .org, .net.
    • Authoritative Servers: Store records for specific domains (e.g., google.com).
    • Recursive Resolvers: Cache and return IP addresses to clients.

DNS Lookup Process

  1. User Request: You type example.com in a browser.
  2. Recursive Resolver Query: Your ISP or a public DNS (e.g., Google DNS 8.8.8.8) checks its cache.
  3. Root Server Query: If not cached, the resolver queries a root server.
  4. TLD Server Query: The root server refers the resolver to the .com TLD server.
  5. Authoritative Server Query: The TLD server refers the resolver to example.com's authoritative server.
  6. IP Address Returned: The authoritative server returns the IP address for example.com.
  7. Response to User: The resolver caches the result and sends the IP to your device.

3. DNS Record Types

Record Type Purpose Example
A Maps domain to IPv4 address example.com → 192.0.2.1
AAAA Maps domain to IPv6 address example.com → 2001:0db8::1
CNAME Alias for another domain www.example.com → example.com
MX Mail server for the domain example.com → mail.example.com
TXT Text records (e.g., SPF, DKIM) example.com → "v=spf1 ..."
NS Authoritative name servers example.com → ns1.example-dns.com
SOA Start of Authority (zone info) example.com → ns1.example.com
PTR Reverse DNS (IP to domain) 192.0.2.1 → example.com

4. Loopback Addresses

What is Loopback?

  • A loopback address allows a device to send network traffic to itself.
  • Used for testing and development without needing a physical network.

IPv4 Loopback

  • Address: 127.0.0.1
  • Hostname: Typically localhost.
  • Purpose:
    • Test network applications locally.
    • Debug client-server applications.
    • Bypass network hardware (e.g., testing web servers).

IPv6 Loopback

  • Address: ::1 (shorthand for 0000:0000:0000:0000:0000:0000:0000:0001).
  • Function: Same as IPv4 loopback but for IPv6.

How It Works

  • When you ping 127.0.0.1 or localhost, the traffic never leaves your device.
  • The operating system routes it internally.

5. Why DNS and Loopback Matter

  • DNS:
    • Enables user-friendly navigation of the internet.
    • Supports load balancing, redundancy, and geolocation.
  • Loopback:
    • Essential for developers to test applications locally.
    • Used in /etc/hosts files to override DNS for testing.

6. Common DNS Tools

  • nslookup: Query DNS records from the command line.
    nslookup example.com
  • dig: Advanced DNS querying (Linux/macOS)
    dig example.com MX
  • ping: Test connectivity to a domain or loopback.
    ping 127.0.0.1

7. Troubleshooting DNS Issues

  • Flush DNS Cache:
    • Windows: ipconfig /flushdns
    • macOS/Linux: sudo dscacheutil -flushcache or sudo systemd-resolve --flush-caches
  • Check DNS Settings: Ensure your device uses valid DNS servers (e.g., 8.8.8.8, 1.1.1.1).
  • Test Connectivity:
    ping google.com

8. Further Reading

⚠️ **GitHub.com Fallback** ⚠️