Hosts file: What is it and how can we use the file? Domain Name Servers (DNS) connect the Internet. They match the IPv4 and IPv6 addresses that are used by servers with domain-identifiable domain names.
It is the equivalent of the Internet phone book. But while DNS is absolutely necessary for its operation Internet, is not the only way to connect IP addresses to domain names. You can also do this with Hosts files by associating mysterious IP addresses with important domain names.
The Hosts file is a file that almost all computers have. Operating systems use it to map a connection between an IP address and a domain name.
It is an ASCII text file and contains IP addresses separated by a blank and then a domain name or domain name. Each address occupies its own line. For example, the 17.172.224.47 number is Apple's IP address.
To place the above address on a Host file, you need to enter the following line with a text editor (we recommend Notepad ++ for Windows and Geany for LInux).
17.172.224.47 Apple.com
In order for a listing to be valid, you can not use site names containing \, /, or http: //.
If you put the # symbol at the beginning of the line, you actually disable the entry. The Hosts file will ignore it and read the following if it exists.
When an entry is valid, o computer will use the address mapping in the Hosts file and not look it up in DNS.
But why do you get into such a process when your DNS provider automatically searches for addresses for you? There are two main reasons.
First - and least importantly - when you are taken to a webpage from the Hosts file, your computer will read the address a few milliseconds faster than it would from DNS.
Using the file you can speed up the resolution of the address you want to visit. If you always visit the same websites (most of us do) you could use the lightweight DNS server Dnsmasq caching. (We will write about Dnsmasq DNS server in a future post). This program automatically saves DNS queries, so that the next time you visit a website, your computer will look for it in the local μνήμη Dnsmasq instead of wasting time looking up DNS. This can save 50% of your DNS lookup time.
But where really useful Hosts files are in that they allow you to block ads, spyware sites, sites with malware and monitoring sites. It can do it very easily simply by preventing your computer from connecting to annoying websites.
Specifically, you can list the sites you do not want to visit in the Hosts file and give them the 127.0.0.1 loopback address by using IPv4 or :: 1 for IPv6 addresses.
What happens next when a website, an email or something else that is trying to lead you to an address you have blocked, the Hosts file bounces and you can not go to the controversial domain.
You will be wondering "how do you know which websites to avoid?" Good question, because there are thousands of them.
Fortunately, there are three server files to get started. They include a great list of well-known ad servers, cookie tracking sites, and other web sites you want to avoid. you will find the files in the following links:
How to make the internet not suck (as much),, hpHostsAnd MVPS Hósts.
There is also the file Hosts File Project, but has not been updated for a year.
To use any of the above hosts, you must first make a backup of the existing Hosts file. I usually rename the existing file to hosts.old.
Next, you create a file called "hosts". Never use an extension called hosts like hosts.txt, just use "hosts".
Where is the Hosts file?
It depends on your operating system and its version.
For Windows, the above MVPS file includes an installation routine.
Windows 10 / 8 requires special instructions see here | |
Windows 7 requires special instructions see here | |
Win Vista requires special instructions see here |
With others, you just copy and paste the master hosts file into the appropriate destination on your computer.
Preparation
Before using your own hosts file on a Windows system that does not belong to a local domain (network), you must disable the Windows DNS Client Service. To do this, log in to an administrator account, click Start, and type "services.msc" in the search. Run it services.msc and double-click on the entry DNS Client. Set the startup type to manual and stop the service.
The security program Windows Defender can also block you. The Windows Security App can detect changes to the Hosts file as an activity of malware. To avoid this, you must tell Defender to ignore the Hosts file by following these steps:
1. Open Windows Defender.
2. On the Settings tab, click Excluded files and locations.
3. In the Files area locations, click the Search button.
4. Locate and click the Hosts file.
Note: By default, the Hossts file is located in the% systemroot% \ system32 \ drivers \ etc folder.
5. Click Add, and then click Save Changes.
6. You can close Windows Defender.
Edit
Immediately afterwards you can edit the hosts file on one of the following paths:
For Windows NT, Win2K and XP, in the path "C: \ windows \ system32 \ drivers \ etc \ hosts" or "C: \ winnt \ system32 \ drivers \ etc \ hosts"
In Windows 7 and Vista, it is in the path "C: \ windows \ system32 \ drivers \ etc \ hosts" or "% systemroot% \ system32 \ drivers \ etc \ hosts"
In Windows 8.x and Windows 10, you will find it in the run "C: \ Windows \ System32 \ drivers \ etc \ hosts"
On Linux or MacOS X systems, login as root or use sudo to move the main hosts file to "/ etc / hosts" or on some systems to "/ private / etc / hosts". An example shell command:
sudo cp ~ / hosts / etc / hosts
The cp command will copy the hosts file from your original ~ / folder to the folder. Once the host file goes into place, you do not have to restart.
If you're having problems, check the hst file again with a text editor and check the IPs and addresses you've added. To fix this, you can either delete the problematic entry (address) or place a # at the beginning of the line that you think presents the problem. Your computer will ignore it.
If all of this fails, you can simply delete the new hst file and replace it with the old one as, as mentioned earlier, you must have created a backup before you make the changes.