Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using ubuntu 12.04 to connect an openvpn server.

Two scripts update-resolv-conf and in /etc/openvpn should be executed then the connection established.

The commands following added to the configure file client.ovpn to make the two scripts run when openvpn connects and stop when openvpn disconnects:

script-security 2
up /etc/openvpn/update-resolv-conf
up /etc/openvpn/
down /etc/openvpn/
down /etc/openvpn/update-resolv-conf

However, during connection only the first script is executed. And every time I have to run the script individually by hand. So I want to know how to get them both work when openvpn tunnel is established?


share|improve this question
up vote 2 down vote accepted

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:


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

share|improve this answer

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

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.