You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have added this code inside newClient() function, between Client name and Password, to let me configure a static IPv4 for the clients.
It has been tested on both Windows and Debian 11 and it works correctly.
Before Code
You must add this option inside "/etc/openvpn/server.conf"
client-config-dir /etc/openvpn/ccd # Assing static IP to the client.
Code
# STATIC IPecho""read -rp "Do you want to assign static IP? (Y/n): " -e -i Y USR_IP_OP
if [[ ${USR_IP_OP}=="Y" ]];thenecho"Static IPv4 must be insde the network subnet"echo"(e.g. 10.8.0.0/24)"until [[ $CLIENT_IP1=~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]];doread -rp "Client IPv4: " -e CLIENT_IP1
doneecho"ifconfig-push ${CLIENT_IP1} 255.255.255.0"> /etc/openvpn/ccd/${CLIENT}fi
Important considerations
It does not check if the IPv4 has already been assigned.
It does not check if the IPv4 is inside the network range.
If you have changed the network mask, you must change "255.255.255.0" to your specific mask.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Static IPv4 for Clients
I have added this code inside newClient() function, between Client name and Password, to let me configure a static IPv4 for the clients.
It has been tested on both Windows and Debian 11 and it works correctly.
Before Code
You must add this option inside "/etc/openvpn/server.conf"
client-config-dir /etc/openvpn/ccd # Assing static IP to the client.
Code
Important considerations
Beta Was this translation helpful? Give feedback.
All reactions