A DNS request is a application layer request that talks to DNS servers. DNS servers stores information that match hostname with its IP address. The standard port for DNS is 53.
The Domain Name System (DNS) is the phonebook of the internet. It is a lookup table for Domain Name-IP address.
google.com is human-readable URL while 172.217.9.78 is machine-readable IP address. When a request is sent and the IP address is unknown, a DNS request will be automatically fired. DNS servers are responsible to return the correct IP address of the given hostname. It happens behind the scenes.
There are 4 types of DNS server:
DNS recursor
A server designed to receive queries from client machines through applcations. Typically the recursor is then responsible for making additional requests in order to satisfy the client’s DNS query.
Root nameserver
The index reference to other specific locations.
Top level domain(TLD) nameserver
Servers that are categorized by the top level domain. For example, google.com’s TLD server is com
Authoritative nameserver
The dictionary of hostname-IP combinations. It returns the IP address for the requested hostname back to the DNS recursor that made the initial request.
There are 8 steps in a DNS lookup:
A DNS recursive resolver receives a request about google.com
The resolver then queries a DNS root nameserver
The root nameserver responds the address of a TLD DNS server
The resolver then queries the TLD server
The TLD server then responds with the IP address of the domain’s nameserver
The resolver then queries the domain’s nameserver
The domain’s nameserver responds the IP address for google.com
The resolver responds the IP address to the client
There are 3 types of DNS queries:
Recursive query
Client expects requested resource record or an error message if the hostname cannot be resolved
Iterative query
Client receives the best answer from the DNS server if the exact hostname cannot be found. Client receives a referral to a DNS server authoritative for a lower level of the domain namespace. Client then makes query to the referral address until an error or timeout occurs.
Non-recursive query
Client queries a DNS server for a record that the DNS server has access to either because it’s authoritative for the record or the record exists inside of its cache.