How to Update Hosts File Entry on Windows machine

How to Update Hosts File Entry on Windows machine

The hosts file is a plain text file which maps hostnames to IP addresses. The hosts file is usually the first process in the domain name resolution procedure. You can map an IP addresses to a domain on your local system through editing hosts file, that can overrule the authoritative DNS. It will allow you to check, what a domain will show if it’s pointed to a different server.

1. Open Notepad as an Administrator. You will need administrator privileges for this operation.

Press the Windows button on your keyboard and type “notepad.” Let the search feature find the Notepad application.

Right-click the Notepad app, then click Run as administrator.



Windows User Account Control should pop up asking, “Do you want to allow this app to make changes to your device?” Click Yes.

You can also open notepad using command line.

a) Press Windows + R keys to Run Line.

b) Paste the following in run line and click ok button

notepad



2. Open the Windows Hosts File

In Notepad, click File> Open

Navigate to c:\windows\system32\drivers\etc

In the lower-right corner, just above the Open button, click the drop-down menu to change the file type to All Files.

Select “hosts” and click Open.



3. Edit the File

The Windows hosts file gives you a brief explanation on how to write a new line. Here’s a brief breakdown:

#    127.0.0.1       localhost

The # sign at the beginning of the line is used to comment a line and it will be executed.

The first set of digits is the IP address you’re mapping. This could be the internal IP address of a server on the network, or it could be the external IP address of a website.

The second label is the name you want to be able to type in a browser to access the server or website at the IP address you just specified.

Once you’re finished making your changes, save the file (File > Save) and exit.



For example if you want to resolve example.com to IP 192.168.1.1 Please add the following line to your hosts file.

192.168.1.1    example.com



The hosts file can be edited to block certain hostnames (like advertising/malicious hosts), or used for web development purposes, i.e. to redirect domains to local addresses.



Times Viewed:
770
Added By:
Brian
Date Created:
9/23/2020
Last Updated:
9/23/2020