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.
Feb 4 08:00:41 192.168.0.1 openvpn[1238]: Re-using SSL/TLS context Feb 4 08:00:41 192.168.0.1 openvpn[1238]: LZO compression initialized
After this point it would just hang. Normally you’d see more:
Feb 4 08:47:07 192.168.0.1 openvpn[3906]: UDPv4 link local: [undef] Feb 4 08:47:07 192.168.0.1 openvpn[3906]: UDPv4 link remote: 10.0.0.1:1194 Feb 4 08:47:12 192.168.0.1 openvpn[3906]: [aegir] Peer Connection Initiated with 10.0.0.1:1194 Feb 4 08:47:14 192.168.0.1 openvpn[3906]: TUN/TAP device tun0 opened Feb 4 08:47:14 192.168.0.1 openvpn[3906]: /sbin/ifconfig tun0 10.1.0.30 pointopoint 10.1.0.29 mtu 1500 Feb 4 08:47:15 192.168.0.1 openvpn[3906]: Initialization Sequence Completed
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):
# start openvpn again if failed (sleep 30 && (ps | grep openvpn | grep -v grep || openvpn --config /tmp/openvpncl/openvpn.conf --route-up /tmp/openvpncl/route-up.sh --down /tmp/openvpncl/route-down.sh --daemon))&
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.
-
-
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
-
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.
-
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. -
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…
-
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-
I just want to say thank you very much for this script. I have spent hours upon hours looking for a fix and this solved it for me. I sincerely appreciate this.
-
-
10 comments
Comments feed for this article
Trackback link: https://www.tolaris.com/2009/02/04/openvpn-on-dd-wrt-v24-sp1-doesnt-start-on-reboot/trackback/