Skip to main content

Domain Name System (DNS)

The Domain Name System (DNS) is one of the most essential โ€” yet often overlooked components of the Internet. Itโ€™s what allows us to use memorable names like codeharborhub.github.io instead of complex numerical IP addresses.

DNS acts as the Internetโ€™s phonebook, translating domain names into IP addresses so browsers can locate and communicate with servers worldwide.

Why DNS Existsโ€‹

Computers communicate using numbers (IP addresses), not words. Before DNS, users had to manually look up and remember numeric addresses โ€” an unscalable and error-prone process.

DNS was created to solve this by introducing a distributed, hierarchical naming system thatโ€™s:

  • Human-friendly: You type names, not numbers.
  • Scalable: Works across billions of domains.
  • Automatic: Queries happen invisibly in milliseconds.

DNS Hierarchy Overviewโ€‹

The DNS system is hierarchical, like a tree:

Each level plays a specific role in locating resources on the Internet.

How a DNS Query Works (Step-by-Step)โ€‹

When you enter a URL such as https://codeharborhub.github.io, your browser performs several steps to find its IP address:

All this happens in a fraction of a second.

The Four Key DNS Server Typesโ€‹

Server TypeDescription
DNS Resolver (Recursive Resolver)Usually provided by your ISP or a public DNS service (like Google 8.8.8.8). It initiates and manages DNS lookups on your behalf.
Root Name ServerThe top-level of DNS โ€” knows where to find TLD servers (like .com, .io, .net).
TLD Name ServerStores information about domains under a specific top-level domain.
Authoritative Name ServerThe final authority โ€” provides the actual IP address for a domain.

Common DNS Record Typesโ€‹

DNS uses resource records (RRs) to store information. Each type serves a specific purpose:

Record TypeDescriptionExample
AMaps a domain to an IPv4 address.codeharborhub.github.io โ†’ 185.199.108.153
AAAAMaps a domain to an IPv6 address.example.com โ†’ 2606:2800:220:1:248:1893:25c8:1946
CNAMEAlias for another domain name.www.example.com โ†’ example.com
MXMail server record (used for email routing).example.com โ†’ mail.example.com
TXTStores arbitrary text info (SPF, DKIM, verification).v=spf1 include:_spf.google.com ~all
NSIdentifies the authoritative name servers for a domain.example.com โ†’ ns1.example.net

DNS Caching โ€” Speed Optimizationโ€‹

To reduce lookup time and network load, DNS results are cached at multiple levels:

  • Browser Cache โ€“ Short-term memory for recently visited domains.
  • Operating System Cache โ€“ Local DNS records stored temporarily.
  • Resolver Cache โ€“ Managed by ISPs or public DNS resolvers.

Each record has a TTL (Time To Live) that defines how long it stays valid before a recheck.

Practical Example โ€” DNS Lookup Flowโ€‹

You type codeharborhub.github.io โ†’ DNS finds its IP โ†’ Browser connects โ†’ Website loads.
Itโ€™s that simple โ€” all automatic.

DNS in Action โ€” Simulationโ€‹

Live Editor
function DnsDemo() {
  const [resolved, setResolved] = React.useState(false);
  const resolve = () => setResolved(true);

  return (
    <div style={{ textAlign: "center" }}>
      <h3>DNS Resolution Simulation</h3>
      <p>Domain: codeharborhub.github.io</p>
      <button onClick={resolve}>Resolve Domain</button>
      {resolved && <p> IP Address: 185.199.108.153</p>}
    </div>
  );
}
Result
Loading...

Security in DNSโ€‹

DNS was designed for speed and reliability โ€” not security. Attackers exploit this through methods like:

  • DNS Spoofing / Cache Poisoning: Injecting false IP mappings.
  • DNS Hijacking: Redirecting users to malicious servers.
  • Amplification Attacks: Overloading DNS servers to cause downtime.

To counter these, DNSSEC (Domain Name System Security Extensions) was introduced. It digitally signs DNS data, ensuring authenticity and integrity.

Key Takeawaysโ€‹

  • DNS is the Internetโ€™s distributed naming system that maps domain names to IP addresses.
  • The DNS hierarchy consists of Root, TLD, and Authoritative servers.
  • DNS uses various record types (A, AAAA, CNAME, MX, TXT) to manage different data.
  • Caching makes DNS fast, while DNSSEC makes it secure.
  • Every click, website, or API request starts with a DNS lookup โ€” itโ€™s the silent foundation of the web.
tip

Learn about IP Addressing โ€” the numerical system that identifies every device on the Internet.