# How tell openvpn to start on wireless? [Solved]

## lelik

laptop has a NIC (eth0) and a Wireless card (eth2).

ifplugd monitors eth0

eth2 connects to the wireless router via wpa_supplicant

dhcpcd assigns an ip to eth2 (wireless) as eth0 (NIC) is not plugged

openvpn client is configured to connect to openvpn server

When trying to start openvpn

```
/etc/init.d/openvpn start
```

getting 

```
WARNING:  openvpn is scheduled to start when net.eth0 has started.
```

How tell openvpn to use net.eth2 instead?

At boot & default level:

```
rc-update -s
```

returns

```

           alsasound | boot

            bootmisc | boot

             checkfs | boot

           checkroot | boot

               clock | boot

         consolefont | boot

                dbus |      default

          fbcondecor | boot

                hald |      default

            hostname | boot

               ivman |      default

             keymaps | boot

               local |      default nonetwork

          localmount | boot

             metalog |      default

             modules | boot

              net.lo | boot

            netmount |      default

             openvpn |      default

           rmnologin | boot

             urandom | boot

          vixie-cron |      default

                 xdm |      default
```

Last edited by lelik on Wed Sep 03, 2008 5:35 pm; edited 1 time in total

----------

## kevstar31

```
nano /etc/init.d/openvpn
```

----------

## lelik

```
nano /etc/init.d/openvpn
```

yields

```
#!/sbin/runscript

# Copyright 1999-2007 Gentoo Foundation

# Distributed under the terms of the GNU General Public License v2

VPNDIR="/etc/openvpn"

VPN="${SVCNAME#*.}"

if [ -n "${VPN}" ] && [ "${SVCNAME}" != "openvpn" ]; then

        VPNPID="/var/run/openvpn.${VPN}.pid"

else

        VPNPID="/var/run/openvpn.pid"

fi

VPNCONF="${VPNDIR}/${VPN}.conf"

depend() {

        need localmount net

        before netmount

        after bootmisc

}

checktundevice() {

        if [ ! -e /dev/net/tun ]; then

                if ! modprobe tun ; then

                        eerror "TUN/TAP support is not available in this kernel"

                        return 1

                fi

        fi

        if [ -h /dev/net/tun ] && [ -c /dev/misc/net/tun ]; then

                ebegin "Detected broken /dev/net/tun symlink, fixing..."

                rm -f /dev/net/tun

                ln -s /dev/misc/net/tun /dev/net/tun

                eend $?

        fi

}

start() {

        ebegin "Starting ${SVCNAME}"

        checktundevice || return 1

        if [ ! -e "${VPNCONF}" ]; then

                eend 1 "${VPNCONF} does not exist"

                return 1

        fi

        local args=""

        # If the config file does not specify the cd option, we do

        # But if we specify it, we override the config option which we do not want

        if ! grep -q "^[ \t]*cd[ \t].*" "${VPNCONF}" ; then

                args="${args} --cd ${VPNDIR}"

        fi

        start-stop-daemon --start --exec /usr/sbin/openvpn --pidfile "${VPNPID}" \

                -- --config "${VPNCONF}" --writepid "${VPNPID}" --daemon ${args}

        eend $? "Check your logs to see why startup failed"

}

stop() {

        ebegin "Stopping ${SVCNAME}"

        start-stop-daemon --stop --exec /usr/sbin/openvpn --pidfile "${VPNPID}"

        eend $?

}
```

----------

## kevstar31

change:

```
depend() {

        need localmount net

        before netmount

        after bootmisc

} 
```

to:

```
depend() {

        need localmount net.lo

        before netmount

        after bootmisc

} 
```

----------

## lelik

Thanks. 

That worked.

Would you mind me asking what it actually did?

----------

## kevstar31

it makes it depend on net.lo instead of net.eth0. net.lo always works because it is simply a loopback interface for communicating within the localhost and does not depend on any Ethernet or wireless connections.

----------

