PDA

Bekijk de volledige versie : openvpn startup issues (works fine manually)



n00dl3s
12-05-2007, 14:15
Hello,

I've been searching the forums, read the nice howto on the Sprayfly-Wiki (http://www.sprayfly.com/wiki/OpenVPN) and googled my fingers sore, but nothing helps...

My problem:
I am running an openvpn server on my wl500g and if i start everything manually everything is working as it should...
However, the automatic startup at boot-time does not...
I am using the bridging approach (tap), and the culprit seems to be, that the tap0 interface is not added to br0 at startup. In effect, i can connect to the openvpn-server, but since tap0 is not enslaved to br0, no connection to any LAN machines is possible.

My init-script is this:

cat /opt/etc/init.d/S70openvpn


#!/bin/sh

if [ -n "`pidof openvpn`" ]; then
/bin/killall openvpn 2>/dev/null
fi

# load TUN/TAP kernel module
/sbin/insmod tun

openvpn --mktun --dev tap0 >> /opt/var/log/openvpn.log 2>&1
brctl addif br0 tap0 >> /opt/var/log/openvpn.log 2>&1
ifconfig tap0 0.0.0.0 promisc up >> /opt/var/log/openvpn.log 2>&1

# enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

# Startup VPN tunnel in daemon mode
/opt/sbin/openvpn --cd /opt/etc/openvpn --daemon --log-append /opt/var/log/openvpn.log --config new.conf



So, after booting i can see that:
* tun module is loaded
* tap0-device is not up
* tap0 is not enslaved to br0

If I run the same script manually after startup, everything works fine. I already experimented a little with delaying the steps ("sleep 10"), but didn't help either...

What am i doing wrong? Any help appreciated...

n00dl3s
12-05-2007, 16:08
Ok, stupid-me found the error for himself after reading his own post here in the forum...

The problem was, that $PATH is not set correctly yet when the script gets executed. So, if I replace

openvpn --mktun --dev tap
with
/opt/sbin/openvpn --mktun --dev tap
everything is alright.

I just wonder why I got it right further down the script...

Anyway, maybe somebody else runs into the same problem although that's probably not that likely ;)