Run script in Debian 6 when VPN is established
Posted on 2011-10-19
I'm a relative novice in the inner workings of Linux... so I apologize if this is a very basic question...
I have a Linux box running Debian 6 (Squeeze). One of the applications that runs at startup is OpenVPN which establishes a VPN connection (tun0). I have a script which I currently run manually after startup which establishes routing over the VPN - it is just a series of "ip route add" statements which point packets bound for various IP ranges to the VPN tunnel.
I'm trying to find a way to run this script automatically when the box starts but can't figure out how to do this. Also it sometimes takes up to 30 seconds for the VPN to establish and if the script runs too soon it fails because the system does not yet know about tun0.
<> Is there a way to get the script to run after an extended delay (say 60 seconds)?
<> Better, is there a way to get the script to run automatically when the tun0 interface comes up?
<> Or is there a better way of achieving what I'm trying to do?
I'm running the box in console mode - so no GUI.
Thanks for your help,