|
| 1 | +--- |
| 2 | +title: “Use Pihole VPN with Wireguard in 2024” |
| 3 | +date: 2024-02-27 |
| 4 | +descripton: “Use Pihole VPN with Wireguard | In this tutorial, I will show you how you can use Pihole on the go with the help of VPN.” |
| 5 | +hero: /images/posts/pihole/pihole-raspberry-vpn.png |
| 6 | +menu: |
| 7 | + sidebar: |
| 8 | + name: Pi-hole with WireGuard and piVPN |
| 9 | + identifier: pihole-vpn |
| 10 | + parent: pihole |
| 11 | +categories: |
| 12 | +- “Linux” |
| 13 | +- ‘Network’ |
| 14 | +- “Security” |
| 15 | +- “Tutorials” |
| 16 | +- “Video” |
| 17 | +tags: |
| 18 | +- “linux” |
| 19 | +- “pi-hole” |
| 20 | +- “security” |
| 21 | +- ‘tutorials’ |
| 22 | +- “video” |
| 23 | +--- |
| 24 | +## Pihole VPN - No ads on your smartphone |
| 25 | +In this tutorial, ‘**pihole VPN with Wireguard**’, I would like to show you how you can use the ‘**PiVPN**’ application to access your **Pihole** on your **smartphone, tablet, or laptop** and thus enjoy the benefits of Pihole, namely surfing without annoying ads, even when you're **on the go**. |
| 26 | +I'll show you how it all works in my video on my YouTube channel! |
| 27 | + |
| 28 | + |
| 29 | +### Prerequisites for this tutorial |
| 30 | +To make setting up a VPN server with Pi-hole as easy as possible, your setup must meet the following requirements. |
| 31 | + |
| 32 | +> ### Note |
| 33 | +> |
| 34 | +> **If you do not meet these requirements, you can recreate the individual requirements here:** |
| 35 | +> |
| 36 | +> - [Install Pi-hole](https://secure-bits.org/pi-hole-auf-einen-raspberry-pi-installieren/ “Install Pihole on a Raspberry Pi”) |
| 37 | +> |
| 38 | +> - [Pi-hole and Fritzbox](https://secure-bits.org/fritzbox-pi-hole-fritzbox-konfigurieren/ “Configure Fritzbox for Pihole”) |
| 39 | +> |
| 40 | +> - DynDNS with DuckDNS |
| 41 | +> - Optionally, I would recommend securing SSH access |
| 42 | +Secure SSH access |
| 43 | +- **A finished and running Pi-Hole instance on a Raspberry Pi or similar (VM, Banana Pi, etc.).** |
| 44 | +- **The Pi-hole is set up as an internal DNS server on your Fritzbox.** |
| 45 | +- **You have set up a DynDNS address in your Fritzbox (e.g., DuckDNS).** |
| 46 | +Optional: |
| 47 | +- **Secure SSH access** |
| 48 | +## Video tutorial on ‘pihole VPN with Wireguard’. |
| 49 | +{{< youtube 4N0fkV7nS6k >}} |
| 50 | +## Commands for setting up Pi-hole, PiVPN, and WireGuard |
| 51 | +All commands I use in the video to install PiVPN and configure Pi-hole and WireGuard are listed here in chronological order. |
| 52 | +### Please note! |
| 53 | +This blog post only summarizes the commands for installing and setting up PiVPN with Pi-hole. **You can see the individual setup steps in the video!** |
| 54 | +### Pihole VPN - Installing the UFW firewall |
| 55 | +To secure the Raspberry Pi with Pi-hole and PiVPN, the UFW firewall is installed and configured on the system. |
| 56 | +```bash |
| 57 | +# Installing the UFW firewall |
| 58 | +sudo apt install ufw |
| 59 | +# Configuring the UFW firewall |
| 60 | +sudo ufw allow 80,53,67/tcp |
| 61 | +# Only allow SSH access from your internal network area. Important!!! Adjust the IP address range (in this example 192.168.178.0/24) to your network area if necessary |
| 62 | +sudo allow from 192.168.178.0/24 to any port 22/tcp<figcaption> |
| 63 | +sudo ufw allow 53,67,58120/udp # 51820 is the port for WireGua<figcaption> |
| 64 | +# When using IPv6 |
| 65 | +sudo ufw allow 546:547/udp |
| 66 | +# Activating the firewall |
| 67 | +# Please note that the correct port for SSH is specified above in the rules! Otherwise, you will lock yourself out via SSH! |
| 68 | +sudo ufw enable |
| 69 | +``` |
| 70 | +### Pihole VPN - Installing and setting up PiVPN on the Raspberry Pi |
| 71 | +Here are the commands for installing PiVPN on the Raspberry Pi. |
| 72 | +```bash |
| 73 | +# Command to install PiVPN |
| 74 | +sudo curl -L https://install.pivpn.io | bash |
| 75 | +``` |
| 76 | +#### PiVPN WireGuard - Command list |
| 77 | +Here is a list of all commands for configuring WireGuard under PiVPN as well as the PiVPN package itself. |
| 78 | +```bash |
| 79 | +# List of all commands for PiVPN WireGuard |
| 80 | +pivpn -a -> Create client |
| 81 | +pivpn -c -> List all connected clients |
| 82 | +pivpn -d -> Start a debugging session for troubleshooting |
| 83 | +pivpn -l -> List all configured clients |
| 84 | +pivpn -qr -> Display a QR code for configuring a mobile client (e.g., cell phone, tablet with the WireGuard app) |
| 85 | +pivpn -r -> Delete a client |
| 86 | +pivpn -h -> Display the help dialog |
| 87 | +pivpn -u -> Uninstall PiVPN |
| 88 | +pivpn -up -> Update PiVPN |
| 89 | +pivpn -bk -> Create a backup of the VPN configurations and user profiles |
| 90 | +``` |
| 91 | +### Additional information on the topic ‘Pi-hole VPN’ |
| 92 | +For more information on this topic, I have compiled some links here: |
| 93 | + |
| 94 | +**Everything about WireGuard:** |
| 95 | + |
| 96 | +- [https://www.wireguard.com/](https://www.wireguard.com/) |
| 97 | + |
| 98 | +**Everything about PiVPN:** |
| 99 | + |
| 100 | +- [https://docs.pivpn.io/](https://docs.pivpn.io/) |
| 101 | + |
| 102 | +- [https://github.com/pivpn/pivpn](https://github.com/pivpn/pivpn) |
0 commit comments