Merge pull request #1279 from DerDanilo/support_setupvars_for_wg_net_and_allowed_ips

Support setupVars for pivpnNET, subnetClass and ALLOWED_IPS via unattended setup
This commit is contained in:
4s3ti 2021-04-21 23:52:56 +02:00 committed by GitHub
commit bf7c4593d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 9 deletions

View file

@ -24,7 +24,6 @@ piholeSetupVars="/etc/pihole/setupVars.conf"
dnsmasqConfig="/etc/dnsmasq.d/02-pivpn.conf"
dhcpcdFile="/etc/dhcpcd.conf"
subnetClass="24"
debianOvpnUserGroup="openvpn:openvpn"
######## PKG Vars ########
@ -1067,10 +1066,18 @@ installPiVPN(){
$SUDO mkdir -p /etc/pivpn/
askWhichVPN
# Allow custom subnetClass via unattend setupVARs file. Use default if not provided.
if [ -z "$subnetClass" ]; then
subnetClass="24"
fi
if [ "$VPN" = "openvpn" ]; then
pivpnDEV="tun0"
pivpnNET="10.8.0.0"
# Allow custom NET via unattend setupVARs file. Use default if not provided.
if [ -z "$pivpnNET" ]; then
pivpnNET="10.8.0.0"
fi
vpnGw="${pivpnNET/.0.0/.0.1}"
askAboutCustomizing
@ -1092,17 +1099,24 @@ installPiVPN(){
# set the protocol here.
pivpnPROTO="udp"
pivpnDEV="wg0"
pivpnNET="10.6.0.0"
# Allow custom NET via unattend setupVARs file. Use default if not provided.
if [ -z "$pivpnNET" ]; then
pivpnNET="10.6.0.0"
fi
vpnGw="${pivpnNET/.0.0/.0.1}"
# Allow custom allowed IPs via unattend setupVARs file. Use default if not provided.
if [ -z "$ALLOWED_IPS" ]; then
# Forward all traffic through PiVPN (i.e. full-tunnel), may be modified by
# the user after the installation.
ALLOWED_IPS="0.0.0.0/0, ::0/0"
fi
# The default MTU should be fine for most users but we allow to set a
# custom MTU via unattend setupVARs file. Use default if not provided.
if [ -z "$pivpnMTU" ]; then
# Using default Wireguard MTU
pivpnMTU="1420"
fi
# Forward all traffic through PiVPN (i.e. full-tunnel), may be modified by
# the user after the installation.
ALLOWED_IPS="0.0.0.0/0, ::0/0"
CUSTOMIZE=0
installWireGuard

View file

@ -4,6 +4,8 @@ IPv4gw=192.168.23.1
dhcpReserv=0
install_user=pi
VPN=openvpn
pivpnNET=10.8.0.0
subnetClass=24
pivpnPROTO=udp
pivpnPORT=1194
pivpnDNS1=9.9.9.9

View file

@ -1,9 +1,9 @@
IPv4dev=eth0
IPv4addr=192.168.23.211/24
IPv4gw=192.168.23.1
dhcpReserv=0
install_user=pi
VPN=wireguard
pivpnNET=10.6.0.0
subnetClass=24
ALLOWED_IPS="0.0.0.0/0, ::0/0"
pivpnMTU=1420
pivpnPORT=51820
pivpnDNS1=9.9.9.9