When it comes to advertising and avoiding all that kind of intrusive or annoying ads for us, we often resort to the use of ad blockers, of which one of the best known is Adblock or for more extreme users blocking these with the host file.
Even if you are a user of a Raspberry Pi I can tell you that you can use it to block ads at the router level.
So we will use Pi-hole for this task, a server program that can be installed and run on Raspbian perfectly.
Pi-hole installation
To install this application on our Raspberry Pi, the first thing we will have to do is update our system, so we must open a terminal and in it type:
apt-get update
apt-get upgrade
Finished this now cWe will start with the installation of Pi-hole, which we can obtain by typing the following command
curl -sSL https://install.pi-hole.net | bash
Running this the Pi-hole installation wizard would start so initially it will tell us that it needs a static IP address.
Go ahead and press OK and then you must choose between Wi-Fi and Ethernet.
Once they have chosen, the installation wizard will ask them if they want to "use your current network settings as a static IP address".
Once they hit 'the installation wizardIt will properly install the packages and notify you when it is complete along with the IP address to access the panel and a password which you must write down.
Redirecting traffic
Once the installation is done, we must force all the traffic to now go through our Raspberry, so we must carry out this configuration on our devices.
This part will be different depending on your operating system:
Windows
Right click on the Start button and select Network Connections, then right click on your Ethernet or Wi-Fi network and select Properties
Double click on Internet Protocol version 4 (TCP / IPv4) and then on "use the following DNS server addresses"
Here they must enter the IP address of their Raspberry Pi as the preferred DNS server.
Click OK and then once again OK
OS X
Click on the Apple menu and navigate to System Preferences> Network> [your network]> Advanced> DNS, after that you must click on the plus sign on the left and enter the IP address of your Raspberry Pi
And finally they have to click on accept and then apply
Android
Go to Settings> Wi-Fi, here you must press and hold your current network and then you must navigate to «Modify network> Show advanced options».
Status here, we are going to change the IP configuration to static, so you are going to enter the IP address of your Raspberry Pi in DNS 1. Once the changes are made, you just have to click on save.
iOS
Go to Configuration> Wi-Fi> [your network]> DNS, in this section you will enter the IP address of your Raspberry Pi.
Once you've done this, you should no longer see ads.
Creating White List of Ads
As you know, most of the websites and blogs are maintained by advertising on them, so if you are a conscious user you can allow the advertisements of these sites that you want to support.
For this we can create a white list of sites. For this They must go to the Pi-hole interface in their browser, this they will do with the IP address and access data that I previously mentioned that they will save.
With these data you can log into the Pi-hole interface, within the Pi-hole administration interface you should go to the section that says “White list” here you can add all those sites in which you want it to be shown advertising.
In the same way they can create a black list of those sites from which they want to block, this they do in the same way as the white list, only they have to go to the “Black List” section.
Interesting information, and excellent to apply in SMEs. Thanks a lot.