In the early days of the internet the hosts file was created. It is a text file which stores the domain name you are going to (www.example.com) and the IP address where it is hosted (184.108.40.206).
It is just like an address book, it stores your friends phone numbers for when you want to contact them. Originally network admins had to store every domain they knew about in hosts file but this was quickly replaced when the internet became so big this was impossible. This information is now provided by a service called DNS (domain name service) but nearly every system still supports the hosts file.
It is very useful to know that the hosts file is checked before DNS and therefore can be used to overwrite DNS on your computer. This is immensely useful for testing, development work and moving things around on the internet. We regularly use hosts files to test websites on new servers without interrupting normal site visitors.
How to change your hosts file:
Windows 10 and 8
1. Press the Windows key
2. Type “Notepad” into search
3. Right click on the Notepad app and select “Run as administrator”
4. From Notepad, open the following file: “c:\Windows\System32\Drivers\etc\hosts”
6. Save the file
1. Open up the terminal (this is found in Applications/Utilities)
2. sudo nano /private/etc/hosts
4. Save the file (ctrl-x and then y)
You will need to clear the system cache before your changes are loaded in.
5. sudo killall -HUP mDNSResponder
1. Open a terminal
2. sudo vim /etc/hosts
4. Save the file
I am in my hosts file, now what?
Hosts files are written as so:
ip.ad.dr.ess domain names
For example if you wanted all traffic to dogsbody.com (and www.) to instead go to 220.127.116.11:
18.104.22.168 www.dogsbody.com dogsbody.com
Finally remember to revert your changes when you have finished testing!
Migrating websites? updating DNS? kerfufled? contact us today