tech image

Hosts File- One Computer File You Should Know About

When last did you open your computer host file to see if the domain mapping to the IP address was still safe?

When last did you open your computer Hosts file to see if the domain name mapping to IP address are still safe?

There may be times when the websites we visit might look similar to the original one, but they are not.

This is because an adversary may have by the help of a malware manipulated your computer Hosts file to redirect you to a malicious website that looks similar to the genuine one.

Hosts file is an operating system file that maps domain names to IP address. It helps in translating human-friendly hostnames into numeric protocol addresses, called IP addresses.

This sounds so much like a computer jargon right? let us break it down a little.

Whenever you type in a website address on a browser like www.google.com; what happens is that the address you typed in will be converted into a number like 216.58.223.206 called IP address which computer understands better. Though this conversion is done for you in the background by Domain Name System (DNS) on the internet.

That means that if I type in 216.58.223.206 on the browser address bar instead, I will still be taken to www.google.com website as the two are the same.

Therefore, the same work DNS does for you on the internet by changing the text address you typed to the corresponding IP address is what the Hosts file does on your computer locally.

You can use it to change the IP address of a website before it gets out to the internet.

So, if I edit my computer Hosts file by adding this single line of text on it;

157.240.29.35 www.google.com

What happens is that whenever you type in www.google.com on my browser you will be taken to the IP address 157.240.29.35 instead, which is a Facebook website instead of google.

Adding this line 127.0.0.1 www.google.com instead will take you back to your computer whenever you enter the google web address on the browser and you will not be able to visit google website from your computer again.

Despite the security implications of the Hosts file, there are some useful things you can do with this file which includes;

Restricting people from visiting a particular websites on your computer.

Or redirecting people to the website you want whenever they want to visit a particular website on your computer.

And as a parent, you can also use it to manage the type of resources your children can visit on their computer.

How to Locate and Edit Hosts File on Your Windows Computer

Two things you should note is that the Hosts file is a plain text file and you can edit it using the notepad application on your Windows computers.

And for security purposes, you must have administrative permission on a computer before you can edit the Hosts file of the computer.

The simple way to get this permission to edit this file on windows is by running your Notepad text editor as administrator and then use it to open the file.

This you can do by right-clicking on your notepad application icon and selecting Run as administrator.

Once you have opened your Notepad in administrator mode, the next thing is to go to the menu at the top of your Notepad application select File and then select Open.

Then, navigate to the folder where the Host file is saved. Below is the path;

1. Select your C:\ drive to open it

2. Then scroll down to select the Windows folder from the list of folders that will appear.

3. Then select the system32 folder

4. Scroll to till you see drivers folder and open it.

5. Then scroll down again to the etc folder and open it too. This folder might look empty.

6. Then type in hosts on the file name box at the bottom and click open. This will display the Hosts file content on your notepad as shown below.

hosts file

Do not change any of the file’s content instruction, that starts with the # symbol.

To add a new IP address mapping to the file; do so at the bottom of the file content on a new line. So that each IP mapping should be on an individual line.

You can also check for malicious redirect on the Hosts file by finding IP address mapping that has something else other than 127.0.0.1.

When you see any IP address like the google example above. You will have to delete it if you are not the one that added it.

Remember also that some malware can block you from connecting to websites that help in updating your system security, by mapping them to 127.0.0.1 IP too.

So, check also if you are being denied access to websites related to your system security by a malware.

Remember, every computer has a Hosts file. In Mac, you can get it in the etc/hosts path.

How to Get the IP address of a Website

To get an IP address equivalent of any website; you can do so using ping command on your Command Prompt or Terminal.

Simply type ping www.google.com on the command prompt and hit enter on your keyboard.

The result will look as shown below.

Leave a Reply

Your email address will not be published. Required fields are marked *

you're currently offline