The Internet Protocol can only route packets to an IP address, not a name. So, if you try to connect to a website, such as example.com, your system must first resolve that domain name, example.com, into an IP address for the server that hosts that website.
This is done by connecting to a Domain Name System (DNS) server. You connect to a domain name server by knowing in advance its IP address. The IP address for a domain name server is usually assigned by your ISP.
Many other domain name servers are made publicly available by different organizations. Here are a few free and public DNS servers:
DNS Provider | IPv4 Addresses | IPv6 Addresses |
Cloudflare 1.1.1.1 | 1.1.1.1 | 2606:4700:4700::1111 |
1.0.0.1 | 2606:4700:4700::1001 | |
FreeDNS | 37.235.1.174 | |
37.235.1.177 | ||
Google Public DNS | 8.8.8.8 | 2001:4860:4860::8888 |
8.8.4.4 | 2001:4860:4860::8844 | |
OpenDNS | 208.67.222.222 | 2620:0:ccc::2 |
208.67.220.220 | 2620:0:ccd::2 |
To resolve a hostname, your computer sends a UDP message to your domain name server and asks it for an AAAA-type record for the domain you're trying to resolve. If this record exists, an IPv6 address is returned. You can then connect to a server at that address to load the website. If no AAAA record exists, then your computer queries the server again, but asks for an A record. If this record exists, you will receive an IPv4 address for the server. In many cases, a site will publish an A record and an AAAA record that route to the same server.
It is also possible, and common, for multiple records of the same type to exist, each pointing to a different address. This is useful for redundancy in the case where multiple servers can provide the same service.
We will see a lot more about DNS queries in Chapter 5, Hostname Resolution and DNS.
Now that we have a basic understanding of IP addresses and names, let's look into detail of how IP packets are routed over the internet.