How to use Raspberry Pi to improve your web-surfing experience with Pi-Hole + PiVPN

Anton Elisee
4 min readApr 7, 2021

In this modern world, people are leveraging the widespread of the World Wide Web in an insurmountable number of ways. Whether it’s improving business, gathering a huge following, or just making life easier (thanks Google), the power of millions and billions of people being connected via an Internet connection is crazy and still gaining more power by the minute. But it’s not all good and peachy though. Hackers, malware, and intrusive ads are the tip of the iceberg of less-than-desirable things we have all experienced while being on the ‘net.

I’m sure lots are now aware of Pi-Hole, a service that performs DNS-level blocking of known ad and malware URLs. In other words — ads on the block list don’t even make it to your screen.

You just set it up on your host device, make some changes to your router, and ads no more! And this is an awesome service, except, it’s only running in the confines of your network.

That’s where PiVPN comes in. It’s basically a bunch of scripts, bundled into a simple installation process that makes your device into an endpoint to connect to your home internal network. Not impressed yet? Well, with Pi-Hole running alongside PiVPN, you got ad-blocking on the go, wherever there’s an internet connection!

The biggest catch is that you have to forward a port on your router and configure the VPN service to actually allow the client devices that it is supposed to allow. But the devs at PiVPN make this easy as possible! With their simple terminal commands and ever-improving documentation, it’s rather trivial to get it set up, add the devices you need, and walk away.

To get started, all you need is Raspberry Pi(or any Linux box with a supported distro: Prerequisites — Pi-hole documentation (pi-hole.net)) to act as a server, another device that can act as an SSH client, and an Internet connection(wired connection highly recommended).

Once you’ve got SSH setup on your Pi/device, and you’ve ran the updates, it’s as simple as a one-liner through SSH in the server’s terminal:

sudo curl -sSL https://install.pi-hole.net | bash

That’ll bring you to an installer where you can setup a static ip for your Pi-Hole, and do some configuration on the Pi-Hole service(add block lists, enable web interface, etc.).

Just that easily, you’ve now got a blackhole for all incoming ads on your network, as well as a cool, sleek web interface to manage everything. You can access it by entering the IP in a web browser (http://192.168.X.X/admin). All you have to do now to get the ad-blocking is point the DNS server of all your devices to the IP address of the Pi-Hole, and enjoy! For best results, you may want to disable DHCP on your router, and enable DHCP on the Pi-hole’s web interface. This will force any device connecting to your Internet to use Pi-Hole as the DNS server.

Now it’s time to block ads on-the-go. Getting PiVPN setup is just as simple, run a cURL command to download what’s needed:

sudo curl -L https://install.pivpn.io | bash

These installers make setup easy-peasy.

The installer gives you the choice of the 2 big VPN protocols, OpenVPN and WireGuard. There are loads of difference, and it really chalks down to freedom of configuration(OpenVPN), vs. speed and simplicity(WireGuard). I’d go with the newer, faster WireGuard.

It’ll ask which port you want to use, you’ll have to login to your router(default gateway’s) web interface, and forward that same port on your router. You can normally find the web interface by typing 192.168.1.1 or 192.168.1.254 into a browser.

Let’s add a smartphone to get on-the-go ad blocking. Download the WireGuard app from the App/Play Store. Run the command pivpn add, it prompts for a client name(I put “Phone”), then, run pivpn -qr, scan the QR code with your phone from the WireGuard app, and we are connected safely! You can do this for as many clients as you need to.

Whether you’re a geek or not, there is a sense of accomplishment that comes with conquering the battle of loud and unsightly ads on your favorite websites/blogs. Even though ads, and ad revenue is a business in and of itself, it’s grown to really bring unsatisfaction to us consumers. Unfortunately for them, technology is creatively destructive, and with Pi-Hole + PiVPN, advertisers have found themselves on the latter end of that spectrum.

--

--