Fix dynamic IP assignment in OpenVPN

This commit is contained in:
Johan 2025-03-21 07:25:23 +01:00
parent c336788346
commit 2b310143d7

View File

@ -61,9 +61,8 @@ if ufw status | grep -q "Status: active"; then
systemctl restart ufw
fi
if [ ! -f /etc/openvpn/myserver.conf ]; then
if [ ! -f /etc/openvpn/myserver.conf ] || [[ " $@ " == *" --force "* ]]; then
tee /etc/openvpn/myserver.conf > /dev/null <<EOL
#public-host $VPN_PUBLIC_HOST
port $VPN_PUBLIC_PORT
proto udp
@ -74,7 +73,7 @@ cert myservername.crt
key myservername.key
dh dh.pem
server $VPN_SUBNET.0 255.255.255.0
server $VPN_SUBNET.0 255.255.255.0 nopool
ifconfig-pool-persist /var/log/openvpn/ipp.txt
client-config-dir /etc/openvpn/ccd
topology subnet
@ -155,11 +154,11 @@ persist-key
cipher AES-256-CBC
ncp-ciphers AES-256-GCM:AES-128-GCM
auth SHA1
# tls-client
tls-client
client
resolv-retry infinite
remote $VPN_PUBLIC_HOST $VPN_PUBLIC_PORT udp
# remote-cert-tls server
remote-cert-tls server
float
verb 3