How to use the hosts file to block malware and ads
The hosts file customizes the typically automatic domain name rendition to IP addresses. While not very noticeable, Domain Name System () facilitates quick browsing.
Experts dub this decentralized naming structure as the ultimate digital phonebook. While DNS simplifies our digital life, there are ways to configure it to your preferences.
Almost all operating systems have a hosts file, mapping hostnames to IP addresses. Some customization can contribute to fighting malware and repetitive ads.
What is a hosts file?
Hosts files present you with a feasible way to manipulate how hostnames convert into distinct combinations of numbers. By default, DNS deals with all these requests and seamlessly connects you to associated IP addresses.
While consistent conversion is undeniably essential, users cannot instruct DNS servers to modify their repositories. A hosts file rests in operating systems for this exact purpose.
The document accepts new entries that override the usual DNS routes. Operating systems show preference to hosts files and do not contact DNS to convert hostnames listed in them.
The hosts file is an ordinary text document. You can simply edit it via the Notepad editor. The redirects apply solely to your OS and won’t affect the DNS repositories in any shape or form.
Since hosts files arrange new hostname conversion guidelines, they could replace parental control software. However, these DNS-overriding documents effectively block potentially dangerous websites and ads.
What are the benefits of using a hosts file?
- Reducing loading time. Since the hosts file resolves address requests, the process takes fewer milliseconds to complete. DNS lookup takes longer to perform, but the differences are far from ground-breaking. Furthermore, it might be physically impossible to add entries for every domain. However, you can change the conversion process for websites you visit regularly.
- Preventing malicious ads or websites. Hosts files are ideal for blocking domains or ads involved in questionable ordeals. Correct entries will force your OS to drop requests to load such content. Instead, it will redirect you to safety, making you bounce away from the questionable source. Since we cannot always trust our judgment, automatic redirection works as an efficient barricade.
How to efficiently block harmful content?
- Downloading ready-to-use hosts files. Cross-checking domains’ respectability could become an endless task. So, instead of adding each entry manually, you can employ existing lists. They contain dozens of entries, all redirecting you away from questionable domains. You will find many available repositories of suspicious addresses. However, don’t be hasty to copy-paste just any list as it could be just as dangerous. “How to make the internet not suck (as much)” offers an of domains you can copy-paste. Additionally, Steven Black offers a similar file in .
- Entering individual entries. Configuring the hosts file manually is not difficult but can get repetitive. All you have to do is open the document and add entries of domains you wish to block. Before typing in the name, you can include 0.0.0.0. The latter instructs requests to lead to a nonexistent target instead of the original. It is a dominant route taken to perform ad-blocking. While the hosts file can encompass an unlimited number of entries, they might render invalid. For instance, you need admin rights to modify these documents. Furthermore, all entries must comply with the correct syntax. If any of these conditions are faulty, DNS servers will resolve hostname requests.
How to access and modify hosts files?
- Launch Notepad by opting for the “Run as Administrator” option.
- Find the hosts file in the c:\Windows\System32\Drivers\etc location. Select “All Files” filter.
- Add an entry by starting with 0.0.0.0. Then, type the domain name (as shown in the example).
- You can also copy-paste entries from pre-arranged lists.
- Save the changes and exit.
- Open Terminal by searching for it via your Launchpad.
- Type in “sudo nano /private/etc/hosts” in the Terminal and press enter.
- You will need to provide a password. After that, the editor will open.
- Add an entry by starting with 0.0.0.0. Then, type the domain name.
- Save the changes via “Control + X” shortcut. Click the mouse cursor, type “y”, and press Enter.
- Launch Terminal (or use shortcut CTRL + ALT + t).
- Type in the following command: “sudo nano /etc/hosts.”
- Confirm access with a password and open the hosts file.
- Start writing entries: 0.0.0.0, followed by the domain name.
- Press “Control + X” combo and pick “y” to end and save the changes.
During this process, you must not add an extension to the hosts file. If it ends with .txt or any other variation, the entries will be invalid.
Of course, the changes are easily reversible. Simply access the file in the same manner, and delete the outdated entry.
Atlas VPN continues to polish its Shield feature to serve a similar purpose. It blocks access to suspicious without you having to do any manual setup. Hence, you will be safe from accidentally entering websites wishing you harm.