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:
Google Public DNS
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.