What is Hosts File:
The Hosts file is a text file which has map hostnames to IP addresses. If you type URL in the browser, it will check the hosts file and if it is located, then it will redirect to the IP which you have provided, otherwise it will go to the IP via DNS server of your active connection.
The Hosts file is used to block certain hostnames. It can be edited and you can even block host names on your own. Now I’m going to show you how to edit Hosts file in both MAC OS X and Windows Operating System.
How to Edit Hosts File in Mac OS X
Open Terminal from Applications/Utilities
Type SUDO NANO /PRIVATE/ETC/HOSTS and press Enter. Then type the Admin password if asked.
Now Hosts File is opened. Tap the Down Arrow key to bring the cursor down and start adding your Hostnames and IP addresses.
Press Control+O followed by ENTER/RETURN key to Save the Hosts File. Flush the DNS to take effect. Now you can ping or type the URL in the browser to check.
How to Edit Hosts File in Windows
Open My Computer and Navigate to the Primary Partition which consist of Operating System and go to WINDOWS/SYSTEM32/DRIVERS/ETC
Copy the Host File to the Desktop to Edit. (You cannot be able to edit the file inside that Folder).
Open the Host file with the Notepad which you copied earlier to the Desktop.
Add your Hostnames and IP Addresses then Save the File.
Now Copy or Cut the File from the Desktop and Paste it in the Windows/System32/Drivers/Etc. Replace original Host file with the one which you edited. Flush the DNS to take effect. Now you can ping or type the URL in the browser to check.
Tips to Consider When Editing Hosts Files
- You can consider few tips that can be applied to hosts file.
- You can Redirect your hostnames to desired IP addresses.
- You can add # symbol to add Comment inside the Hosts file, for future reference.
- You can Block applications while connecting to some addresses.
- You can Block websites through Hosts File.
Video Tutorial is embedded for your Convenience. If you have any doubts, drop it in Comment Section.