Add something like the following to your client.conf file:

script-security 2 # run /etc/openvpn/ when the connection is set up up /etc/openvpn/

Obviously, must be executable. Also, if you expect the command to fail but still want Openvpn to start correctly (it will die if the script returns anything other than 0), then tack on an “exit 0? at the end of your script.

Thx to askubuntu.

Mario Loria is a builder of diverse infrastructure with modern workloads on both bare-metal and cloud platforms. He's traversed roles in system administration, network engineering, and DevOps. You can learn more about him here.