Ad blocking VPN with DNS over HTTPS on a Raspberry Pi4
Tags: vpn, https, pihole, raspberrypi
Published: 2021-01-02 01:45:41

*Originally Posted https://darnahsan.medium.com/ad-blocking-vpn-with-dns-over-https-on-a-raspberry-pi4-d2c608895211 Published on August 13th, 2020*

I recently bought a Raspberry Pi4 with just an idea of setting up an OpenVPN node for fun. Once it arrived it felt like a COVID19 impulse buy 😅 when I could have gotten an instance in cloud for as low as 4 SGD and use it for almost 3 years to break even the cost. So I started exploring what more could I do, while doing more and more DuckDuckGo searches I realized I could set up an Ad blocking DNS using PiHole. As there is now the hype of DoH — DNS over HTTPS, so I explored if I could do that and yes there was a way OSS FTW. Once I settled on Pi hole and cloudflared for an Ad blocking DoH for home network, I wanted to setup a VPN which would not just be a VPN but an Ad blocking VPN. I have been using and advocating ppl to use Blokada to run a localhost VPN and block ads on their devices and I do that on my mobile, tablet and even TV but when I had to use a VPN and turn off bloakda there would be a wave of #Ads that would hit me. My initial pick was based on the most commonly known option OpenVpn but turns out the Raspberry Pi4 doesn’t have the power to do crypto efficiently but I thought it was a compromise worth making that is when I stumbled across WireGuard protocol the new kid on the block which is simpler and faster and less resource hungry than OpenVpn and simpler to setup also 😅. Once settled on all the components it was time to set them up on the Pi and setup some port forwarding on the router. God bless Docker as I didn’t wanted to install each of these and run into dependency pains on ARM64 architecture. Hooked it all using Docker Compose and now I have a VPN that has Ad blocking built in and at home a WiFi that blocks all ads on my devices. The biggest win of running the VPN from home is the residential IP I get as most of the VPNs use data centers that give limited speed and bandwidth and have a bad reputation and are blocked by service providers. It feels like an achievement 😂 so will put out the repo for anyone to be able to run this setup at home and #ReclaimYourInternet. Yes there are plenty of tutorials over how to set them up but not all 3 together so it takes some effort to know what you have to do. I know ppl would think can just install a plugin such as Adblocker in broswer and get done with it at home but then again they are collecting all the data its just that they sell it "anonymised". Block them at the source and protect your data. The results are pretty decent, the latency is lower and the upload speeds are similar on the VPN. Overall its a win win utilisation of the Pi4. 😁

Also don’t forget all those commercial VPN services you pay for log every bit of your browsing history and then they lose it on the internet and it ends up for sale on the #DarkWeb. Never trust anyone with your browsing history 😜

As committed here is the repo for #Constantine a setup for an Ad blocking #VPN with #DNS over #HTTPS using #cloudflared + #pihole + #WireGuard. Currently running on a #RaspberryPi4 #Docker composed

#OSS
{% github ahsandar/constantine %}

![](https://cdn-images-1.medium.com/max/2160/1*pjxYb6OpYHnsEly8H4wPRA.jpeg)

![](https://cdn-images-1.medium.com/max/2160/1*9ppB875rXG_TN1zgi9iNLw.jpeg)