How to add new hostfile Tutorial
Credit to : How-to-Geek
Modifying your hosts file allows you to override the DNS for a domain, on that particular machine. This is useful when you want to test your site without the test link, prior to going live with SSL; verify that an alias site works, prior to DNS changes; and for other DNS-related reasons. Modifying your hosts file causes your local machine only to look directly at the IP address specified.
The following sections provide instructions for locating and editing the hosts file on several operating systems. After you add the domain information and save the file, your system begins resolving to the specified IP address. After testing is finished, remove these entries.
- Windows 8 or 8.1 or 10
- Windows 7
- Ubuntu
- Mac OS x (any version)
Windows 8 or 8.1 or 10
First, Press the window key. Type notepad in the search field, then right-click on Notepad in the search results list, and choose to run it as administrator. If you’re using Windows 10 this will be on the Start Menu.
If you’re using Windows 10, it’ll look more like this:
Once you’re done, In Notepad, open the following file:
1 |
c:\Windows\System32\Drivers\etc\hosts |
Then you can edit to the file. Once you’re done, Click File > Save or CTRL + S to save.
Windows 7
To access the hosts file in Windows 7 you can use the following command in the Run Line to open Notepad and the file :
1 |
notepad c:\windows\system32\drivers\etc\hosts |
Once Notepad is open, you can edit the file.
After you edit your Hosts file make sure to save it by click on File > Save or CTRL + S.
Ubuntu
In Ubuntu 10.04 and most Linux distro’s you can edit the hosts file directly in the terminal. You can use your favorite editor or even open your favorite GUI text editor. For this example we will use VIM. If you don’t have VIM you can refer from this; How to install VIM. Like Windows 7, Ubuntu’s hosts file is located in the /etc/ folder, though here it is in the root of the drive. In order to edit the file you will need to open it as root which is why we use sudo here.
Now that it is open we can edit it to redirect Facebook into nothing. You will notice that with Ubuntu there is also a section for IP6. For most needs you will only need to edit it the top section and ignore the IP6.
Then save the file.
Mac OS X (Any version)
In OS X, accessing the hosts file is very similar to Ubuntu. Begin in terminal and use your favorite editor, even is you wish to call a GUI text editor, it is easier to do so from terminal.
The file will look a bit more like Windows, only with a little less explanation. We are going to redirect Facebook.
This time it seems that 0.0.0.0 is a loopback and will direct you to the computers Apache test page.
Recent Comments