tirsdag 8. april 2014

HOWTO Start Dante Socks server together with OpenVPN client during reboot in Ubuntu 12.04

After installing Dante SOCKS server it would not start during reboot, thee problem was the OpenVPN tun0 interface was not up when dante was starting, and it would not start with error tun0 not found.

I did quite a bit of googling before a solution came to me, i did find it on the page: Turn your Raspberry Pi into a VPN gateway.

Here is a overview of the solution (slightly modified for the original):

First remove the normal start and stop hooks in rc*.d
sudo update-rc.d danted remove
Next create the scripts.
sudo mkdir /etc/dante_scripts
sudo nano /etc/dante_scripts/myprovider.up
Add the following contents to /etc/dante_scripts/myprovider.up:
#!/bin/bash
if [ "$1" = tun0 ]; then
 /etc/init.d/danted start
fi
sudo nano /etc/dante_scripts/myprovider.down
Add the following contents to /etc/dante_scripts/myprovider.down:
#!/bin/bash
if [ "$1" = tun0 ]; then
 /etc/init.d/danted stop
fi
Make the scripts runnable:
sudo chmod +x /etv/dante_scripts/*
Add the hooks to /etc/default/openvpn:
sudo nano /etc/default/openvpn
Modify the OPTARGS:
OPTARGS="--up /etc/dante_scripts/myprovider.up --down /etc/dante_scripts/myprovider.down"