Dev.to · 5 min read

Networking Essentials for Software Engineers – Part 3: What Happens When You Type a Website Name?

Networking Essentials for Software Engineers – Part 3: What Happens When You Type a Website Name?

Imagine we open our browser and type google.com. We want to visit Google's website. But how does our browser know which server to contact? Computers use IP addresses to communicate across networks. So, our browser needs to find an IP address associated with google.com before it can connect to the website. We could use IP addresses directly, but imagine having to remember the IP addresses of Google, YouTube, Amazon, and every other website we visit. And those IP addresses might change over time. Remembering website names is much easier than remembering a bunch of numbers, right? That's why we have DNS (Domain Name System). DNS helps us find the IP addresses associated with domain names such as google.com. But how does DNS know which IP address belongs to a particular domain? To understand that, we first need to know how domain names are organized and where their IP address information is stored. Understanding Domain Names Let's take mail.google.com as an example. If we look closely, it has three parts separated by dots (.). mail — Subdomain: Google uses this to identify a particular service, such as Gmail. google — Second-Level Domain: This is the main name registered by Google under .com. .com — Top-Level Domain (TLD): This is the last part of the domain name. Top-level domains help organize domain names into different categories or groups. For example: .com — Originally used for commercial businesses, but now used by all kinds of websites. .org — Originally intended for organizations and commonly used by nonprofits. .in — Represents India. Now, let's see how DNS finds the IP address associated with a domain name. Browser Requests the IP Address: When we type google.com, Chrome needs its IP address to connect to the website. So, it starts a DNS lookup, usually by asking the operating system to resolve the domain. Checking the Cache: Before contacting an external DNS server, the browser or operating system checks whether the IP address is already cached. If a valid answer is available, it can use that directly. Contacting the DNS Resolver: If the IP address isn't available locally, our computer sends a request to a DNS resolver, often provided by our Internet Service Provider (ISP). If the resolver already has the answer cached, it returns it immediately. Root DNS Server: If the resolver doesn't have the answer, it contacts a Root DNS Server. The root server directs it to the DNS servers responsible for .com. Top-Level Domain (TLD) DNS Server: The resolver contacts a .com DNS server, which tells it which authoritative DNS servers are responsible for google.com. Authoritative DNS Server: The resolver contacts the authoritative DNS server for google.com. This server holds DNS records for the domain, including its IP address information, and returns the requested record. Returning the IP Address: The resolver returns the IP address to our computer, and Chrome can use it to connect to the website. Who Manages DNS Servers? We saw how different DNS servers help us find a website's IP address. But who manages all these servers? Let's start with the Root DNS Servers. There are 13 root DNS server identities, named from A to M. Does that mean there are only 13 physical servers in the world? No. Each one has multiple servers spread across different locations. These 13 root server identities are operated by 12 different organizations. You might have heard of ICANN (Internet Corporation for Assigned Names and Numbers). It helps coordinate the domain name system. Now, let's say we're building our own website and want to call it agriboon.com. We can't just choose that name and start using it, right? We first need to register it. We can do that through companies like GoDaddy, which are called domain registrars. Once we've registered agriboon.com, we need to connect it to the server where our website is hosted. Suppose our server has the IP address 203.0.113.10. In GoDaddy's DNS management section, we can add an A record like this: agriboon.com → 203.0.113.10 This information is made available through the authoritative DNS servers responsible for our domain. We can also use another DNS provider, such as Cloudflare or AWS Route 53, if we prefer. Now, when someone enters agriboon.com in their browser, the DNS lookup process we discussed earlier can find the IP address we've configured. Let's Try DNS Ourselves Want to find the IP address of a website yourself? If you're using Linux or macOS, open your terminal and run: dig google.com +short This command displays the IP addresses associated with google.com. Try it with other websites by replacing google.com with any domain name. Can Incognito Mode Hide Our DNS Requests? Suppose we open Chrome in Incognito Mode and visit google.com. We might think that since we're using Incognito Mode, no one can see which websites we're visiting. But Chrome still needs to find the IP address of google.com, right? So, the DNS lookup happens as usual, and our Internet Service Provider (ISP) may still be able to see which websites we're visiting. Incognito Mode simply prevents Chrome from saving our browsing history after we close the incognito session. It doesn't hide our activity from the ISP. I hope you now have a better understanding of how DNS helps our browser find a website's IP address and connect to it when we enter a domain name.

This is a summary aggregated from Dev.to. Read the complete article on the original site:

Read full article at Dev.to

More Programming & Dev News