PiVPN with Wireguard and PiHole not working correctly Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
nilsacht
Posts: 24
Joined: Mon Jan 18, 2021 9:33 am

Re: PiVPN with Wireguard and PiHole not working correctly

Post by nilsacht »

can I post this in my wg0.conf?
User avatar
Joulinar
Posts: 5927
Joined: Sat Nov 16, 2019 12:49 am

Re: PiVPN with Wireguard and PiHole not working correctly

Post by Joulinar »

sure, just mask private data like keys or endpoint
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
nilsacht
Posts: 24
Joined: Mon Jan 18, 2021 9:33 am

Re: PiVPN with Wireguard and PiHole not working correctly

Post by nilsacht »

So here is my cat /etc/wireguard/wg0.conf:

Code: Select all

[Interface]
PrivateKey = XXXX
Address = 10.6.0.1/24
ListenPort = XXXX
### begin Nils ###
[Peer]
PublicKey = XXXX
PresharedKey = XXXX
AllowedIPs = 10.6.0.2/32
### end Nils ###
The whole things you hav in your file are missing in my file.
User avatar
Joulinar
Posts: 5927
Joined: Sat Nov 16, 2019 12:49 am

Re: PiVPN with Wireguard and PiHole not working correctly

Post by Joulinar »

nilsacht wrote: Thu Jan 21, 2021 11:24 am The whole things you hav in your file are missing in my file.
Yes because PiVPN did not do the "cool" enhancement as DietPi is doing. Basically DietPi is offering 2 ways to install WireGuard.
  1. via PiVPN (software id 117)
  2. directly / plain WireGuard (software id 172)
Difference is basically on PiVPN you have some kind of management console to manage clients and configs. Means config files are used as they are created by PiVPN. No further adjustments on the server config by DietPi.

While on the DietPi version you have further adjustments on the server config, including some iptables rules but you don't have that management console. However there is a good documentation on our Online Docs how to setup new clients https://dietpi.com/docs/software/vpn/#wireguard



what you could to is to add following lines into wg0.conf after ListenPort = XXXX and before ### begin Nils ###

Code: Select all

PreUp = /boot/dietpi/func/obtain_network_details
PostUp = sysctl net.ipv4.conf.%i.forwarding=1 net.ipv4.conf.$(mawk 'NR==3' /run/dietpi/.network).forwarding=1
PostUp = sysctl net.ipv6.conf.$(mawk 'NR==3' /run/dietpi/.network).accept_ra=2
PostUp = sysctl net.ipv6.conf.%i.forwarding=1 net.ipv6.conf.$(mawk 'NR==3' /run/dietpi/.network).forwarding=1
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o $(mawk 'NR==3' /run/dietpi/.network) -j MASQUERADE
PostUp = ip6tables -A FORWARD -i %i -j ACCEPT; ip6tables -t nat -A POSTROUTING -o $(mawk 'NR==3' /run/dietpi/.network) -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o $(mawk 'NR==3' /run/dietpi/.network) -j MASQUERADE
PostDown = ip6tables -D FORWARD -i %i -j ACCEPT; ip6tables -t nat -D POSTROUTING -o $(mawk 'NR==3' /run/dietpi/.network) -j MASQUERADE
once done save the file and restart WireGuard

Code: Select all

systemctl daemon-reload
systemctl restart wg-quick@wg0.service
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
nilsacht
Posts: 24
Joined: Mon Jan 18, 2021 9:33 am

Re: PiVPN with Wireguard and PiHole not working correctly

Post by nilsacht »

Thats it. It works. Thank you
User avatar
Joulinar
Posts: 5927
Joined: Sat Nov 16, 2019 12:49 am

Re: PiVPN with Wireguard and PiHole not working correctly

Post by Joulinar »

it was a long journey but we fixed it at the end :)
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply