From 3a2ffa191baee0cdd1e2d582a688ca78547e5776 Mon Sep 17 00:00:00 2001 From: Johan Date: Thu, 20 Mar 2025 08:20:56 +0100 Subject: [PATCH] Add static IP assignment to OpenVPN --- BashScripts/add-openvpn-client.sh | 8 ++++++++ BashScripts/install-openvpn-server.sh | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/BashScripts/add-openvpn-client.sh b/BashScripts/add-openvpn-client.sh index 8cb6948..c388fbe 100644 --- a/BashScripts/add-openvpn-client.sh +++ b/BashScripts/add-openvpn-client.sh @@ -15,6 +15,14 @@ if [ -f "/etc/openvpn/easy-rsa/pki/issued/$CLIENT_NAME.crt" ]; then echo Client $CLIENT_NAME already exists... exit 1 fi +VPN_SUBNET=$(grep -E '^server ' "/etc/openvpn/myserver.conf" | awk '{print $2}') +read -e -p "Use static IP for this client? VPN subnet is $VPN_SUBNET (Leave empty for dynamic): " -i "" CLIENT_IP +if [ ! -z "${CLIENT_IP}" ]; then + echo Setting IP... +cat > "/etc/openvpn/ccd/$CLIENT_NAME" <