All Collections
Setup Guides
Manual Router Configurations
How to configure DD-WRT routers - OpenVPN script?
How to configure DD-WRT routers - OpenVPN script?
Steve M avatar
Written by Steve M
Updated over a week ago

This tutorial shows how to connect a DD-WRT router to LimeVPN servers via the OpenVPN protocol, using a script.

1. Go to Administration → Commands in your router settings.

2. Paste this whole text to the Command box:

#!/bin/sh

USERNAME="username"
# Replace "username" with LimeVPN username provided by LimeVPN  

PASSWORD="password"
# Replace "password" with LimeVPN password provided by LimeVPN

 

# United Kingdom

REMOTE_SERVERS=remote xxx.limevpn.com 1194
# Replace xxx.limevpn.com with desired server address and use 1195 if 1194 doesn’t work

#### DO NOT CHANGE below this line ####

 

CA_CRT='-----BEGIN CERTIFICATE-----

MIIDyDCCAzGgAwIBAgIJAMZgKsG36ZrWMA0GCSqGSIb3DQEBBQUAMIGfMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFTATBgNVBAcTDFNhbkZyYW5jaXNjbzEVMBMGA1UEChMMRm9ydC1GdW5zdG9uMRAwDgYDVQQLEwdsaW1ldnBuMRAwDgYDVQQDEwdsaW1ldnBuMRAwDgYDVQQpEwdsaW1ldnBuMR8wHQYJKoZIhvcNAQkBFhBtYWlsQGhvc3QuZG9tYWluMB4XDTE3MDMxNzEwNTc1OVoXDTI3MDMxNTEwNTc1OVowgZ8xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEVMBMGA1UEBxMMU2FuRnJhbmNpc2NvMRUwEwYDVQQKEwxGb3J0LUZ1bnN0b24xEDAOBgNVBAsTB2xpbWV2cG4xEDAOBgNVBAMTB2xpbWV2cG4xEDAOBgNVBCkTB2xpbWV2cG4xHzAdBgkqhkiG9w0BCQEWEG1haWxAaG9zdC5kb21haW4wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAK/mIoDT3+jkomCR8c4Q1uNhMByfQ3wCLiXx/Rkx08a4QtmIDw00vU+ac7VLE6PEaRFfw0akr0KtlcCrv2xccovbgK0WAkn5WSDXCKw6sbqaHmxsUX+iBoa+aouP2JU9lT7dqJH7v1KppeojYW0p40WGsvggXxeDF6OJpXijWs0zAgMBAAGjggEIMIIBBDAdBgNVHQ4EFgQUAYTDQtcNmeEm0gOOlxJst1JsVxcwgdQGA1UdIwSBzDCByYAUAYTDQtcNmeEm0gOOlxJst1JsVxehgaWkgaIwgZ8xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEVMBMGA1UEBxMMU2FuRnJhbmNpc2NvMRUwEwYDVQQKEwxGb3J0LUZ1bnN0b24xEDAOBgNVBAsTB2xpbWV2cG4xEDAOBgNVBAMTB2xpbWV2cG4xEDAOBgNVBCkTB2xpbWV2cG4xHzAdBgkqhkiG9w0BCQEWEG1haWxAaG9zdC5kb21haW6CCQDGYCrBt+ma1jAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAHjjcSTxbDM4MhL6k2hf2V88m0gxf739aPzGCx3eLsm1arHXzmLer0tZiaUL09xX3Me6B8a12iD0GJCpx4zntxabTV7R7sqR7dmiq/7ifI3UJMYlDFHuxrtx39Uoz7SQhR2NXF9hnsA9FD4HwXdK52Y+8xUZvaP5DegoNRY9clGE

-----END CERTIFICATE-----'

 

AUTH_KEY='-----BEGIN OpenVPN Static key V1-----

334197a6762361463c73c45b64cc3d1d

2d8344efef576bdd4905b46552510ffb

9da6860a061bf154cf2c0fbd7b1e7854

053b036cbc9d363c316b452b3f479df0

2ae396cea5104992a35b2ceec79f235e

d4a62c96281ac2a9f90d28990970b387

f6ad2606c39793a5e1b2cd5dc4b934ec

de56fd2ca7474f9a6b6dd113698da4dc

0fa1ea2aea2a9e26e7e49f32b1c09d3b

c57b7bf3619be1126ad738190d0ba5f7

05e42e00993f050c5f7751ba2e8bfe70

ce66cb893f28b65554f37074a3bb1079

9eda840dd013a47ee88591bff8ca3396

ac4026697319b51aae957b71d0151624

a9b97be5f935d5c3b5c771069216e5b4

0875e7ce555006f356b7a8d8a58970ca

-----END OpenVPN Static key V1-----'

 

OPVPNENABLE=nvram get openvpncl_enable | awk '$1 == "0" {print $1}'

 

if [ "$OPVPNENABLE" != 0 ]

then

nvram set openvpncl_enable=0

nvram commit

fi

 

sleep 30

mkdir /tmp/limevpncl; cd /tmp/limevpncl

echo -e "$USERNAME\n$PASSWORD" > userpass.conf

echo "$CA_CRT" > ca.crt; echo "$AUTH_KEY" > auth.key

echo "#!/bin/sh" > route-up.sh; echo -e "#!/bin/sh\nsleep 2" > route-down.sh

echo "#!/bin/sh

iptables -I FORWARD -i br0 -o tun0 -j ACCEPT

iptables -I FORWARD -i tun0 -o br0 -j ACCEPT

iptables -I INPUT -i tun0 -j REJECT

iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE" > /tmp/.rc_firewall

chmod 644 ca.crt; chmod 600 auth.key userpass.conf; chmod 700 route-up.sh route-down.sh

chmod 700 /tmp/.rc_firewall

sleep 30

echo "client

dev tun

proto udp

script-security 2

hand-window 60

verb 3

mute 5

mtu-disc yes

cipher aes-256-cbc

auth sha1

comp-lzo adaptive

tun-mtu 1500

resolv-retry infinite

nobind

persist-key

persist-tun

keepalive 20 120

reneg-sec 0

log limevpn.log

ca ca.crt

tls-auth auth.key 1

daemon

auth-user-pass userpass.conf

remote-random

$REMOTE_SERVERS" > openvpn.conf

ln -s /tmp/limevpncl/limevpn.log /tmp/limevpn.log

/tmp/.rc_firewall

(killall openvpn; openvpn --config /tmp/limevpncl/openvpn.conf --route-up /tmp/limevpncl/route-up.sh --down-pre /tmp/limevpncl/route-down.sh) &

 

exit 0

 

3. Click the Save button.

4. Go to Administration → Management and click the Reboot Router button at the bottom of the page.

5. Once the router is rebooted wait for a minute and you will be connected.

Did this answer your question?