How to Setup Wireguard + Pi-hole on Debian 10 / Ubuntu 18.04

Published: | Last Edited:
Category: tech | Tags: #pi-hole #vpn #wireguard

WireGuard® is an extremely simple yet fast and modern VPN that utilizes state-of-the-art cryptography. It aims to be faster, simpler, leaner, and more useful than IPsec, while avoiding the massive headache. It intends to be considerably more performant than OpenVPN. WireGuard is designed as a general purpose VPN for running on embedded interfaces and super computers alike, fit for many different circumstances. Initially released for the Linux kernel, it is now cross-platform (Windows, macOS, BSD, iOS, Android) and widely deployable. It is currently under heavy development, but already it might be regarded as the most secure, easiest to use, and simplest VPN solution in the industry.


Follow up for my post How to host OpenVPN and Pi-hole on Ubuntu 18.04 VPS. This is a guide to set up wireguard + pi-hole for your own private ad blocking VPN.


Wireguard Setup

Run these scripts:

wget -O && bash

Follow this setup:

Welcome to this WireGuard road warrior installer!

I need to ask you a few questions before starting setup.
You can use the default options and just press enter if you are ok with them.

What IPv4 address should the WireGuard server use?
     1) Your IPv4 address should show up here
     2) other local IP
IPv4 address [1]: 1

What port do you want WireGuard listening to?
Port [51820]: 51820

Tell me a name for the first client.
Client name [client]: client

Which DNS do you want to use for this client?
   1) Current system resolvers
   3) Google
   4) OpenDNS
   5) NTT
   6) AdGuard
DNS [1]: 2

We are ready to set up your WireGuard server now.

Press any key to continue...

Start Wireguard

Wireguard should start automatically after you ran the script. If not you can check by

systemctl status wg-quick@wg0.service

Restart Wireguard services:

systemctl restart wg-quick@wg0.service

Pi-hole Setup

Note down Wireguard’s IP:

ip a show dev wg0 // note this address

Note down your default gateway IP address:

ip r | grep default
default via XXX.XXX.XXX.XXX dev eth0 onlink // note this address

Run this script:

curl -sSL | bash

Follow the instruction to set up pi-hole:

Test DNS settings

Run this script


# Output from host has address has IPv6 address 2607:f8b0:4005:80b::200e mail is handled by 10 mail is handled by 20 mail is handled by 30 mail is handled by 40 mail is handled by 50

Our Wireguard + Pi-hole still see’s public IPs properly

This time run


# Output from host has address has IPv6 address :: is an alias for

Pi-hole blocked as the domain is in its blacklist.

Generate Wireguard Client Config File

Run bash

Configure Wireguard to use Pi-hole DNS

Edit your wireguard client conf file and update the DNS servers setting with Pi-hole internal address. In my case it is

Test From Browser

After connecting to your VPN using Wireguard client. Go to this address, if everything works correctly you will see this: google syndication

Pi-hole Statistics

You can go to http://pi.hole/admin once you are connected to the VPN and see some of Pi-hole’s stats. The result is mind-boggling. Almost half of my traffic is to serve ads. Pi-hole stats


Pi-hole is a good solution to fight against ads on the internet. You should give it a try. That said not all ads are bad. Some creators are reliant on ads as their source of income. If you have someone you support, consider whitelisting the ads for the good cause.


Next Post: [Series] PART I: Set Up and Use SSL to Secure MariaDB on Debian Servers
Previous Post: Donate Compute Power to Folding@Home to Find Cures For Covid-19