On Windows 10 Host file is an important system file which maps the host/site names with its IP addresses. Basically, it translates the hostname to IP and IP to hostname. In other Words, the host file is similar to using a phone book to find the matching phone number of a specific person’s name. Host file is a plain text file without any file extension. On Windows computer, We can edit host file on Windows 10 For custom domain redirects, block websites, or remove malicious entries set by malware. It functions as a local copy of a DNS server.
Post Contents :-
- 1 Edit hosts File on Windows 10
Edit hosts File on Windows 10
While Domain Name System – or DNS – is mostly used for this function (being a centralized and half-automatically managed name resolution system), the HOSTS file can be used as a local name resolution mechanism, and when used in conjunction with other name resolution mechanisms such as DNS, the HOSTS file takes precedence over them. In short, your host file is a form of DNS. Your computer actually looks for your host file before hitting the internet and finding the site you’re searching.
Location of the Hosts File
In Microsoft operating systems, the HOSTS file is located in the following location:
How To Edit Hosts file
Some Times we need to edit the Hosts file, For Different purposes like custom domain redirection, block certain websites, or remove malicious entries set by malware. We can modify the host files using Notepad but, As This is a system file we cant modify this with a normal user account, We need administrator rights. For this, we need to open Notepad As ( Admin )
- On Start menu search type notepad,
- Right click on notepad and select Run as Administrator.
- Here on note pad click on file Select open
- Browse for the following path : C:\Windows\System32\Drivers\etc
- Here Select All Files from the drop-down menu and double click on hosts file.
This will open Host files As Shown Bellow image.
- Here you can custom Redirect domain names,
- Block Certain websites ( Domain )
- remove malicious entries set by malware.
Note: To modify the hosts file, you need to add two entries, including the IP address of the remote host or application to a the friendly address you want to use. for ex : Type the IP address of the remote host or local host followed by the domain or computer name you want to use to reach the device or application. Then Click on File, and select Save.
How the Hosts File Works
The Host File contains lines of text that are made of IP addresses followed by one or more host names or fully qualified domain names (FQDNs). Each field is separated by white space (blanks or tabulation characters).
For example, if you wanted to use the HOSTS file to translate a host name of a computer called “FTPserver” into the IP address of 192.168.1.100, Then We need to Add Bellow line:
The HOSTS file can also translate Fully Qualified Domain Names (or FQDNs) of computers, such as ones used on the Internet.
For example, if you wanted to add a manual line to translate a FQDN of a computer called “webserver.domain.com” into the IP address of 11.06.23.100 you would add this line:
When you ping it, your computer will resolve the name to the correct IP address:
Redirect a Website Using Host File
You Can Redirect Any Website to Another website by modifying the Host file. For Ex: you want your To Redirect YouTube.com to Twitter.com Means when you open Youtube.com on your web browser it automatically redirects to twitter.com.
For this first, we need the Twitter’s IP address. we can Get this by using the ping Command. Open the command prompt by click on Start type cmd and hit the enter key. Now type ping twitter.com -t you will see the twitter.com numeric IP address.
Now on Host file Add the Twitter IP Space and The Domain Name
This line tells our computer to connect Youtube.com to Twitter’s IP address. Type Youtube.com you’ll end up at Twitter!
Create Website Shortcuts using the Host file
You can also modify host file to create “shortcuts” that quickly access websites from any program on your computer. For example, if you’re a Twitter addict, you can associate “t” with Twitter – type t in any web browser’s address bar and you’ll instantly end up at Twitter.
You can also create shortcuts with multiple letters, such as twit. You don’t need a .com, .net, .org, or any other type of extension. However, you can’t use spaces.
To do this, just add the following line to the hosts file and save it:
Now you can type t into any program’s address bar and you’ll end up at twitter.com.
Block websites using host file windows 10
If you want to block your computer from accessing certain websites, you can use the loopback address (127.0.0.1) followed by the domain name (e.g., 127.0.0.1 website.com)
simply add the following entry on Host file and save.
Ex : 127.0.0.1 facebook.com
Remove malicious entries set by malware
Also Sometimes Due to Virus / Malware infection you may notice certain Websites not open on your computer. This is Because malware automatically edits your Host file and make Different entries for Domain Redirection (Ex: Any domain Name automatically Redirect to specific Website ) or Block some websites.
Simply open Host file on Notepad and Clear Other entries set by Malware adware. And left the default entries as shown bellow host file.
Lock Hosts file to prevent hijacking
As some times malware/ Adware redirect web address by altering your host files. A good latest updated antivirus can prevent this hijack but if you want to add another layer of security then the second option is to lock the hosts file so no other program or user except you can rewrite to it without unlocking it.
To prevent Host file hijacks, you may navigate to it, right-click on it, select Properties and make it a Read-only file. This will lock down your Hosts file and prevent anyone or any malware from writing to it.
That’s All About edit hosts file on Windows 10. Note that after make any modification on Host files Restart windows to take effect the changes you have done. I hope now you can easily Modify, Edit hosts file on Windows 10 to Custom Domain Redirection, Block Different Websites etc. Feel any Difficulty while edit host files discuss on comments bellow. Also read: