A popular method used to block ads or domains in browsers is to use adblocking addons. An alternate method is by using the hosts
file of your operating system. This file has mappings of hostnames to IP addresses. By pointing domain names to the 0.0.0.0
IP address they cannot be resolved for access.
$ git clone https://github.com/StevenBlack/hosts.git
$ cd hosts
If you have any entries in your local hosts
file, then add them to the myhosts
file in this repository.
To update the adblocking domain files to their latest versions and to add the myhosts
entries to create a final hosts
file run this command:
$ ./makeHosts
hosts
file with this one:$ sudo cp /etc/hosts /etc/hosts.orig
$ sudo cp hosts /etc/hosts
$ sudo service nscd restart
That is it! You can use any browser or application and the domains in the hosts file will not be accessible from them.
Tried with: Ubuntu 16.04