There are several steps that occur when you go to a website. One of the first things that happens is a DNS query to the websites Nameservers. This works much like looking up a phone number for a business in a phone book. What many people don’t know is that each computer has it’s own “Nameserver” that it queries before looking to the websites Nameservers. This is called your computers “Hosts File”. This allows you to define your own IP addresses for domain names and view them from your computer. This is helpful when you are developing websites and need to view the new site by using the domain name. It may sound complicated at first – but after completing this tutorial things should become more clear.
Steps to Change the Hosts File
- Locate your hosts file.
- The location of the hosts file depends on the Operating System that you are using.
- On Linux and Unix systems, like Mac OSX, the hosts file is located at the following path: /etc/hosts
- On Windows XP the hosts file is located at: \WINDOWS\system32\drivers\etc\hosts
- On Linux and Unix systems, like Mac OSX, you can use this command to open the hosts file: sudo vi /etc/hosts
- You will need to enter your root access information to edit this file.
- See this tutorial for help using VI: http://www.unix-manuals.com/tutorials/vi/vi-in-10-1.html
- On Windows XP simply open the file with Notepad.
- IP Address www.yourdomain.com
- For example to set the domain: www.hostfiletestdomain.com to go to Googles IP we can insert this line: 188.8.131.52 www.hostfiletestdomain.com
- Now when we go to www.hostfiletestdomain.com we should see the Google homepage.
You may have to wait a little while before the changes take affect – however in most cases the changes are pretty much instantaneous.
NOTE: Always remember to remove the entries from your host file after you are done using them.