OpenVPN on DD-WRT v.24 SP1 doesn’t start on reboot

At home I use a router flashed with DD-WRT v.24 SP1 with OpenVPN support to connect to the office private network. I upgraded from v.23 SP2 a few months ago. When I did so, I discovered that OpenVPN doesn’t seem to start automatically. Let’s fix it.

Enabling syslog and collecting it at my laptop, I discovered that OpenVPN actually seems to crash or be killed.

After this point it would just hang. Normally you’d see more:

DD-WRT v.24 seems to have some new features that allow you to apply changes from the web frontend without rebooting the entire OS, but the networking layer restarts. I’m guessing that when this happens OpenVPN is not invited to restart. I hope the devs fix this, but in the mean time I have my own solution.

Login to the web interface and go to Administration -> Commands. Save this as your new Firewall command list (which is run each time you restart networking):

This command waits 30 seconds after restarting networking and checks for the existence of an openvpn process. If it does not find one, it starts it using the same command line as DD-WRT would normally use if the VPN were working. The VPN will now connect within the first minute after rebooting the router.

Tags: ,

  1. Ray Lee’s avatar

    ps | grep openvpn | grep -v grep can be replaced by a pgrep openpvn, if you have pgrep available…

    Reply

    1. tyler’s avatar

      DD-WRT provides only busybox and a few other executables. The reason I’m using grep at all is because the busybox ‘ps’ doesn’t even support switches.

      Reply

    2. tyler’s avatar

      It’s not in the filesystem of the standard v.24 SP1 + OpenVPN build (for 4MB flash).

      Reply

    3. Ray Lee’s avatar

      Hmm, is it not compiled the default BusyBox they provide? DD-WRT’s SVN shows that pgrep should be part of it, as of 8 months ago:

      http://svn.dd-wrt.com:8000/dd-wrt/browser/src/router/busybox/procps/pgrep.c?rev=9739

      Reply

    4. Chris’s avatar

      Hi! I find that with v24sp1, the VPN connection sometimes terminates while the router is apparently still connected to the Internet [though since I use my VPN provider's DNS server, nothing works client-side]. No amount of fiddling with the router will seem to bring the openVPN back up. The longest stretch I’ve managed to keep the connection up is 2 hours. Having to reboot every two hours is more than a little annoying..

      I just added this line into my firewall script and hope it works.

      Reply

    5. Tomi’s avatar

      Hi! I add and save commands: sleep 20 in the Startup

      cd /tmp/openvpn
      sleep 20
      openvpn –config openvpn.conf –daemon

      I add and save commands,e.g.:
      /usr/sbin/iptables -I INPUT -p udp –dport 1194 -j ACCEPT
      in firewall
      Sorry, my English is not very well.

      Reply

    6. samtruman’s avatar

      If i put the # start openvpn again if failed script in firewall script my router doesn’t response after reboot, if i put it on startup script it’s all ok…

      Reply

    7. john’s avatar

      Hi there,
      How to apply this to PPTP situation? please advice. I have same problem but I am using pptp instead of Openvpn. I don’t know the command line. Thanks in advance

      Reply

      1. Tyler Wagner’s avatar

        Sorry, I have no idea what commands are started by pptp. Start by logging in via SSH to the device and using “ps” to see what is running while the PPTP link is up. One of those will be what you need.

        Reply

Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">