Down the Pi Hole...
So I've recently done some experimenting to figure out if I can block ads on Channel 4 and ITVX. I love Ch4 but holy potato there's so many ads! And it turns out ITVX has some banging films on there that I'd definitely watch if it didn't have ads
The answer is yes! By using a device called a "Pi Hole"! A bit like a black hole, but for ads. It does need a little bit of tinkering with a raspberry pi (hence the name) and possibly your router (depending how you want to use it); and there's some upfront costs with the pi in the region of ~£60-£80 and maybe an hour or so's configuration. Totally worth it though for peace of mind imo.
How does it work?
The Pi is gonna sit on your home network and act as either your home network's / TV's DNS server. And we're gonna tell it to block certain "domains". What's DNS and what's a Domain? Well if you really want some light bedtime reading, I've put a short blog here that walks you through it here
What the Pi really does is when you're watching something on Ch4/ITVX and the show hits the ad break, ITV or Ch4's advert servers are gonna try and send a selection of ads to your TV. The Pi Hole steps in and says "none of that thanks" and blocks the network request being made by your TV.
Components
So how do I make one? To build this bad boy we're gonna need a few components. I went with a 1GB Raspberry Pi 4 Model B, a 64GB micro SD Card and then I picked up the power cable, Wi-Fi adapter, heat sinks and a case from Pi Hut. Sadly it looks like the 1GB 4Bs have sold out what with the RAM crisis...

For peace of mind when leaving the Pi on all the time, I wanted to be assured the power cable was the official one. That says far more about soothing my anxiety when leaving it on than any genuine safety concerns. People leave these devices running for years with no issues - mine's been on for over a month solidly and no issues. I also bought the Wi-Fi adapter as sold by Pi Hut as I'd read people could experience issues using non-Pi Hut sold ones.
You can also buy an SD card with the raspberry pi Operating System (OS) pre-installed if you want to avoid flashing it yourself. If you are gonna flash the SD card yourself, then you'll also need an SD card reader. It's cheaper in the long run to flash it yourself if you're going to do more tinkering like this
Raspbian Installation
If you bought the pre-installed Raspberry Pi OS (RPOS) SD card then pop that into the Pi with the wifi adapter plugged in and the power on.
If you didn't buy the pre-installed RPOS, you need to install Raspberry Pi Imager on your PC. Use this app to flash the SD card (note you need an SD card reader to do this) - I used RP 64-bit OS. Make sure to take note of your chosen hostname (e.g. you can see mine's called SuckMiPiHole - see below) and ensure you generate an SSH password (and WRITE THIS DOWN!).
Find the Pi!
Now your Pi is empowered with the power of Linux (huzzah!), you'll need to identify its allocated IP address on the network. I did this via nmap but a much simpler way is to login to your router as an admin and look at the devices connected to your network. If you don't know how to log in to your router as an admin, then take a look at your router. There should be a little card on there that gives you the router IP address and the admin password. E.g. for BT Smart Hub's, the IP address is 192.168.1.254

Remote Access
Once you know the router's IP address you can connect to it using the hostname and SSH (Secure Shell if you didn't know) password you created through the cmd window on Windows, the terminal on Linux, or however the heck you do that on Mac... on Mac!
ssh hostname@IP_addresse.g.
ssh suckmipihole@192.168.1.3looks like this

You son of a gun, you did it!
Assign Static IP address
So now we're in you've officially gained remote access to a device over the command line. Excellent stuff! To ensure maximum security we better check for any updates to the OS or upgrades to any Linux packages (software apps) first
sudo apt update && sudo apt upgrade -yGo make a cup of tea and let than run. Although it may prompt you to say yes or accept a few times.
Once complete, we need to assign the Pi a static IP - so that it's always the same IP address on the network - and then install the Pi Hole software. Setting a static IP address is faiiiirly straightforward using nmtui (Network Manager Terminal User Interface... quite a mouthful!)

To figure out the Pi's IP address (if you need to remind yourself) you'll need to run:
ip rThat'll show the wlan (Wireless Local Area Network) interface through which your Pi is connected to your network. Then run nmtui to edit this connection. We have to run it with sudo (super user do) because it requires elevated privileges to run
sudo nmtui
Edit this connection to set a specific static IP address that this device will always have on your wifi. I went with 192.168.1.3. Because pi = ~3. Yes. I am that sad. Yes. For DNS I set 9.9.9.9, better known as Quad9 as they're committed to privacy (unlike CloudFlare and Google). Make sure to hit "OK" - bottom right - when you're done!

Installing the Pi Hole software
Okay we're maybe 70% there. With the static IP address, we can install the pi software. Of course, if you changed the Pi's IP address you'll lose your SSH connection and you'll need to re-SSH to it
Happily, the official install script handles everything for you
sudo curl -sSL https://install.pi-hole.net | bashWhen going through the install, I followed the guidance here in section 2 setting the interface to wlan0, upstream DNS as Quad9 with DNSSEC (to prevent sneaky ISPs sniffing my traffic!) and DEFINITELY install the admin interface and set a password. This gives us a web server we can access from any other device on our home network

The Pi Hole Web Server
You can now access the Pi Web Server from any other device on your network using the static IP you set, plus the admin password. Just navigate to that IP address in your browser

Type your password and hey presto, you're in! And you'll be greeted by a dashboard like this

Blocking ITV and Ch4
To block these ads I manually added a series of domains to the Domains as "exact deny". I'm in the process of trying to create a list to automate this, but haven't quite got there yet

- ads.channel4.com
- cdn.http.anno.channel4.com
- cdn.ss.anno.channel4.com
- channel4.com.sc.omtrdc.net
- channel4.com.ssl.sc.omtrdc.net
- ic.channel4.com
- monitor.channel4.com
- sexperienceuk.channel4.com
- webstat.channel4.com
- webstats.channel4.com
- c4-ads-creative-prod.s3.eu-west-2.amazonaws.com
- channel4.com.112.2o7.net
- thumbs.channel4.com
- c4googletv.2cnt.net
- config.bsd.client.streaming.channel4.com
- ar.prd.content.itv.com
- tom.itv.com
- ned.itv.com
- recommendations.prd.user.itv.com
- ie1-bid.adsrvr.org
- license.theoplayer.com
- licensing.theoplayer.com
- promoted.hubsvc.itv.com
- cpt.itv.com
- profile.prd.user.itv.com
Last but not least
Lastly, you need to add your pi's IP address as the DNS server for your TV. You can do this in the network settings of your TV, though you will need to manually configure this to prevent the router acting as your TV's DNS server.
Congratulations. A bit of elbow grease, but you've just gone ad-free on Ch4 and ITVX!!
