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 need to run a bash script BEFORE connecting to a vpn (which I do by clicking the network manager applet).

I need this script because when connecting to the vpn the routes are incorrect. The script needs to run before connecting to the vpn because I need to use the command "host" to set new routes and if the vpn has already started I cant access internet.

I would also need to run another script when the vpn disconnect so I can roll everything back to normal.

How can I achieve this?

I am using ubuntu 10.04 lts.

share|improve this question

I use Ubuntu but I guess it is same for all distros. Here is the solution for your problem.

share|improve this answer
Please consider adding some excerpt from the linked article. – bytebuster Nov 26 '12 at 15:03

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.