How to execute multiple scripts when openvpn establishes?

Just for reference. If you have a few scripts and timing isn't crucial you can also use another parameter for executing scripts.

Script Order of Execution

--up
Executed after TCP/UDP socket bind and TUN/TAP open.
--tls-verify
Executed when we have a still untrusted remote peer.
--ipchange
Executed after connection authentication, or remote IP address change.
--client-connect
Executed in --mode server mode immediately after client authentication.
--route-up
Executed after connection authentication, either immediately after, or some number of seconds after as defined by the --route-delay option.
--client-disconnect
Executed in --mode server mode on client instance shutdown.
--down
Executed after TCP/UDP and TUN/TAP close.
--learn-address
Executed in --mode server mode whenever an IPv4 address/route or MAC address is added to OpenVPN's internal routing table.
--auth-user-pass-verify
Executed in --mode server mode on new client connections, when the client is still untrusted.

https://openvpn.net/index.php/open-source/documentation/manuals/65-openvpn-20x-manpage.html


A quick hack would be to call the 2nd script from the end of the last one:

Just add the following to the end of the '/etc/openvpn/update-resolv-conf' script:

/etc/openvpn/vpn-up.sh

I'm sure people here will provide a more elegant way to do this.

Tags:

Vpn

Openvpn