OVERVIEW:
This primer briefly explains the purpose of DNS and the HOSTs file.
DNS:
When you want to reach a destination on the internet, you need to know the IP address. The IP address looks something like this: 173.35.33.219. Most people cant remember the IP address as easily as a website name like “wpengine.com.” For this reason, there exists DNS servers which store a directory of domain names and their respective IP addresses. When you go to a website address, your browser goes to the DNS server, looks up the domain’s IP address, and then uses that IP to connect to the server where the website is hosted.
HOSTS FILE:
The hosts file is stored locally on your computer. When you want to reach a particular website, before querying the DNS server to look up the IP address, your computer checks the hosts file first. If you have a domain associated to an IP address in the hosts file, your computer will use that IP address without bothering to check what is on the DNS server.