Lesser known but critical file, hosts file, is a simple text file without a file extension is designed to map or override IP addresses before accessing a DNS (domain name server). In simple words, the “hosts” file overrides any request to a DNS server for a domain name resolution, meaning that you can override where your computer connects to by editing this file as you wish. Another benefit of using the hosts file is precedence.If a hosts file exists, it is automatically searched during any process using the OS TCP/IP stack. The search is done first before any attempt to find a DNS server is made.
Lets say your website is deployed on your test server with IP@ 192.168.1.3 and would exist on mysite.com domain well pushed LIVE. So, you must want to see how your website and its pages are behaving when Domain Switching would done on your Production and available to end user. The simple solution is update the hosts file on your local machine with below configuration:
192.168.1.3 mysite.com
So, once you save the hosts file with this configuration, you can browse the complete website using http://mysite.com on your web browser. Isn’t that Simple & Reliable?
Location of Hosts File
Windows 8, 7, Vista, XP & NT/2000 | %SystemRoot%system32driversetc |
Mac OS X | /private/etc/hosts |
iOS, Android, Unix/Linux | /etc/hosts |
Other hidden benefits of hosts file includes:
- Substitute One Domain Name For Another
- Blocking Malware or Undesirable Sites
- Ad blocking
- Speeding Up Browsing
Enjoy!!