Many people use an ad blocker like uBlockOrigin to block ads from tracking us around the web but this only works on the devices it is installed on. We can do one better and prevent them all across any network in our control.
Method 1: Hosts file.
This method has the least overhead of the two and is great if you just want to get something up and running. Ideally, you would want a separate device to, but you can do this with any computer.
Every computer has a hosts file that holds data for converting domain names to their IP addresses. When you open one for the first time, it is pretty bare, and all requests get directed to your router for lookup.
- Log into the computer or device you want to use as your new DNS server. I am using a Raspberry Pi 2.
- Open Steven Black's Hosts Git Repo, scroll down, and find the file that works best for you. I am using the
Unified Hosts + Porn. Click the link to the "Raw Hosts File," and you will see an enormous list of domains.
- Open your hosts file
a. Linux & Mac OS X:
- Copy and paste the raw text from step two into your hosts file. You can overwrite the file or create a symlink if you want. The file hosted on Github has all the bits required it the hosts file.
- Log into your home router.
- Find the IP address of the device you just added the hosts file too
- Copy this address and set is as your new DNS server for your router. (I can't walk you through this because they are all different.)
That's it! Now you have a network level ad blocker!