#+TITLE:
#+AUTHOR: Bob Mottram
#+EMAIL: bob@freedombone.net
#+KEYWORDS: freedombone, pi-hole, ad blocker
#+DESCRIPTION: How to block ads on your network
#+OPTIONS: ^:nil toc:nil
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="freedombone.css" />

#+BEGIN_CENTER
[[file:images/logo.png]]
#+END_CENTER

#+BEGIN_EXPORT html
<center>
<h1>PI-Hole: The Black Hole for Web Adverts</h1>
</center>
#+END_EXPORT

Idiots who have an inflated sense of self-entitlement will tell you that it's /your moral duty/ to view their mind-numbingly tedious corporate ads on their web site or YouTube channel, or else their kids will starve and the sky will fall because their revenue stream will dry up. But that's bullshit. There is nothing intrinsic or morally mandatory about adverts propping up the livelihoods of netizens, and indeed a web not primarily based on advertising money might have been a much better and more interesting place by now, with a lot less spying.

Not only are web ads annoying, but they can consume a lot of bandwidth, be a privacy problem in terms of allowing companies to track your browsing habits and also any badly written scripts they contain may introduce exploitable security holes. Also if you're poor then adverts often make you want things that you can't have.

You can block ads for any devices connected to your local network by installing the *pihole* app from *Add/Remove Apps* on the administrator control panel. This may help to improve overall performance of your devices by not wasting time downloading unwanted images or scripts.

Also don't expect perfection. Though many ads may be blocked by this system some will still get through. It's a constant cat and mouse game between advertisers and blockers.

* Set a static IP address

Ensure that your system has a static local IP address (typically 192.168..) using the option on the control panel. You will also need to know the IP address of your internet router, which is usually *192.168.1.1* or *192.168.1.254*.

When that's done select *About this system* from the control panel and see the IPv4 address. You can use this as a DNS address in two ways:

* On each client system within your local network

Make sure that you add the static IP address for the server to */etc/hosts*.

#+begin_src bash
STATIC_IP=[your server static IP]
sudo echo "$STATIC_IP [your domain name]" >> /etc/hosts
#+end_src

On Arch/Parabola:

#+begin_src bash
sudo pacman -S openresolv
sudo sed -i "s|#name_servers=.*|name_servers=$STATIC_IP|g" /etc/resolvconf.conf
sudo sed -i "s|name_servers=.*|name_servers=$STATIC_IP|g" /etc/resolvconf.conf
sudo chattr -i /etc/resolv.conf
sudo resolvconf -u
#+end_src

Or on a Debian based system:

#+begin_src bash
sudo apt-get install resolvconf
echo 'domain localdomain' > /tmp/resolvconf
echo 'search localdomain' >> /tmp/resolvconf
echo "nameserver $STATIC_IP" >> /tmp/resolvconf
sudo mv /tmp/resolvconf /etc/resolvconf/resolv.conf.d/head
sudo chattr -i /etc/resolv.conf
sudo resolvconf -u
#+end_src

* On your internet router
If you can access the settings on your local internet router then this is the simplest way to provide ad blocking for all devices which connect to it. Unfortunately some router models don't let you edit the DNS settings and if that's the case you might want to consider getting a different router.

Edit the DNS settings and add the IPv4 address which you got from the control panel About screen. Exactly how you do this will just depend upon your particular router model. You may also need to set the same address twice, because two addresses are conventional.

** LibreCMC
On a router running LibreCMC from the *Network* menu select *DHCP and DNS*. Enter the static IP address of your Freedombone system within *DNS Forwardings*, then at the bottom of the page click on *Save & Apply*. Any devices which connect to your router will now have ad blocking.

* Configuring block lists
You can configure the block lists which the system uses by going to the *administrator control panel*, selecting *App Settings* then choosing *pihole*. You can also add any extra domain names to the whitelist if they're being wrongly blocked or to the blacklist if they're not blocked by the current lists.



#+BEGIN_EXPORT html
<center>
Return to the <a href="index.html">home page</a>
</center>
#+END_EXPORT
