Chapter 2
Domain Names
In the previous chapter, we saw that:
👉 To load a web page, your browser must send a request to a web server.
👉 The Internet Protocol (IP) uses IP addresses to distribute messages worldwide.
Today, you'll understand how the client knows the server's IP address to send its request.
IP Addresses
When you connect to the Internet, your Internet Service Provider (ISP, like AT&T, Verizon…) automatically assigns
you an IP address. It allows your computer to send and receive messages on the network. It's the same principle as
the town hall assigning a postal address to your new restaurant.
In IP version 4, which predominates on the Internet, an address looks something like 82.189.34.250. It's a series of
4 numbers between 0 and 255.
When the IP protocol was created in the 70s, nobody imagined the Internet's explosion on such a large scale.
Nowadays, everything is connected to the Internet: security cameras, cars… IPv4 reached its limits.
A bit of a scare on February 3, 2011, when the last IPv4 address was assigned 😱.
Fortunately, since the 90s, researchers have been working on its successor : IPv6.
Faster, more secure, and allowing billions of billions of IP addresses.
An IPv6 address looks like: 2001:db8:3c4d:15:0:d234:3eee
Internet big players have been engaged in a massive migration from v4 to v6 for years. You're likely to encounter
both formats.
Domain Names
Your new restaurant now has a postal address. But "Come to 1234 Pancake Lane, Syrupville, WA 98765" doesn't sound very
appealing. So, you give your restaurant a name “Henry's”, which you must communicate to various organizations to
be listed in local directories. Customers can now find you just by using this name.
Similarly, it would be super tedious to have to remember the IP addresses of all sites. Imagine having to type
http://2001:db8:3c4d:15:0:d234:3eee to contact me 🥲. What a nightmare!
Thus, in the 70s - 80s, the concept of domain names was developed.
the-tech.guide, google.com, ohhappy.dev… these are all aliases masking an IP address.
When you purchase a domain name from a registrar, they register it with directories.
The directory system that resolves the IP address from the domain name is called DNS: Domain Name System.
The DNS
A domain name is composed of several parts. For instance, for fr.the-tech.guide :
- guide: top-level domain (TLD). TLDs are managed by private companies, states, cities… For example, .fr is managed by Afnic, a non-profit association.
- the-tech: second-level domain (SLD).
- fr: subdomain.
DNS does not rely on a single directory. It's a recursive process that queries several directories until it finds the definitive answer.
- When you connect to the Internet, your ISP provided the address of its DNS server: its directory. When you type the-tech.guide into your browser, it sends a request to this DNS server. As the-tech.guide is the best newsletter in the game 😎, your ISP probably already knows the associated IP address and can directly return it to your browser.
- If the ISP doesn't know the address, it sends a request to a root DNS server: entities distributed worldwide to ensure network availability. The root server can give the address of the registry managing a TLD: .guide.
- The ISP sends a request to this registry. It provides the address of the authoritative registry for .the-tech.guide.
- One last request gets the address for fr.the-tech.guide.
- The ISP returns the information to your browser.
- Only after all this can your browser send a request to the web server to display the website 🤯. That explains why your first visit to a new website often takes longer to load. In a future chapter, we'll talk about caching systems that speed up this process.
Alternative DNS
Whether you're on Mac, Windows, Linux…, you have the option to use a different DNS server than your ISP's. You'll
find this in the network settings of your Wi-Fi or Ethernet connection.
Several reasons might lead you to do this: speed of resolution, security against malicious websites,
automatic ad-blocking, and especially bypassing censorship and surveillance.
Governments, for reasons of fighting piracy, political oppression, etc., can force ISPs to
block certain websites. However, it's much harder for them to impose their will on alternative DNS servers. Be
careful, though, these DNS may belong to large, non-neutral groups.
The most famous are:
- Cloudfare: 1.1.1.1
- Google: 8.8.8.8
- Open DNS, Cisco: 208.67.222.222
- Quad9: 9.9.9.9
- AdGuard (ad blocker): 176.103.130.130