Introduction to DNS

- DNS: A decentralized system that translates domain names to IP addresses. Maps human-friendly domain names (e.g., google.com) to their corresponding IP addresses.
- Purpose: Ensures users do not need to memorize IP addresses. Allows users to access websites using domain names instead of IP addresses.
- Analogy: Similar to a phone book or contacts list where names map to phone numbers.
- Example: When accessing a website (e.g., google.com):
- DNS translates domain names into IP addresses.
- When a user types a domain name into their browser, the DNS system retrieves the corresponding IP address and sends it back to the client.
- This allows the user's request to be directed to the appropriate server.
- The server at the IP address responds, and the webpage is displayed.
- Clients can access a website by entering either its domain name or its corresponding IP address in the browser.
- Using a shell command (
nslookup google.com) to get the IP address of a domain.
- Demonstration of accessing Google by its IP address(
142.251.211.238) directly, showing it leads to the same website as typing the domain name
Contributors to DNS Operations: ISPs, ICANN, and Registrars
-
Internet Service Provider (ISP): Facilitates interaction with DNS servers.
-
ICANN (Internet Corporation for Assigned Names and Numbers): Manages all domain names globally.
- Ensures uniqueness of domain names.
- Works with domain registrars to sell domains.
-
Domain Registrars: Accredited resellers of domain names (e.g., Google Domains, Namecheap, GoDaddy).
Steps Involved in Accessing Neetcode
- User Input:
- The user enters
neetcode.io into their browser.
- DNS Query Initiation:
- The browser initiates a DNS query to resolve the domain name to an IP address.
- ISP Involvement:
- The query is first sent to the user's Internet Service Provider (ISP).
- The ISP checks its local DNS cache. If the IP address of
neetcode.io is not found, it proceeds with further queries.
- DNS Server Query:
- The ISP's DNS server queries the
.io TLD DNS server, managed by the organization designated by ICANN for the .io domain.
- read more about TLD DNS
- Domain Registrar's Role:
- The
.io TLD DNS server provides the address of the DNS server managed by the accredited registrar for neetcode.io (e.g., Google Domains, Namecheap, GoDaddy).
- The registrar’s DNS server, which holds the authoritative DNS records for
neetcode.io, returns the IP address.
- Response and Caching:
- The ISP's DNS server receives the IP address, caches it for future queries, and sends it back to the client's browser.
- Establishing Connection:
- The browser uses the IP address to establish a connection with Neetcode's server.
- Content Delivery:
- Neetcode's server receives the request and sends the requested webpage back to the client.
- Page Display:
- The browser displays the Neetcode webpage to the user.
Static and Dynamic IP Addresses
- Static IP Addresses: Rarely change, making DNS resolution straightforward.
- Dynamic DNS: Allows IP addresses to change but is less common
Caching
When your device accesses a website, its DNS resolver saves the result. If you visit the same site again, the device uses the cached IP address, reducing query time and speeding up access.
ISPs cache DNS queries on their servers. If a query matches a cached entry, the ISP returns the IP address from its cache, cutting down on resolution time and reducing queries to upstream DNS servers.
URL Components
Breakdown of a URL: protocol, subdomain, domain name (primary domain), top-level domain (TLD), path, and parameters.