Configuring a OpenVPN Client on OpenWRT

Recently I set up a OpenVPN Client on OpenWRT. All the instructions are fragmented. Found a forum which had some instructions that worked.
I am mirroring the instructions so that I have a reference to them.

So I’ve been messing around and have a VPN connection running!
All wiki’s or how-to’s I found were just utter crap, so for future reference and anyone else having trouble with it, this is what I did:

– Install the OpenVPN package
– upload your key, conf and crt files to /etc/openvpn
– If needed, edit the conf file to your liking
– SSH into your OpenWRT using putty (root) and cd into /etc/openvpn
– openvpn –config mullvad.ovpn (replace with your conf file name)
– If you get the message “Initialization Sequence Completed”, openvpn is running, but you’ll notice you don’t have internet access
– Go to Network > Interfaces and make a new Interface
– Name it vpn_interface, choose protocol ‘unmanaged’ and select tun0 as the covered interface (this one’s new after you’ve started openvpn)
– Assign this interface to the wan firewall zone
– We want openvpn to start when the router boots, so go to System > Startup and at the bottom put this

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

/usr/sbin/openvpn --cd /etc/openvpn --daemon --config /etc/openvpn/mullvad.ovpn &

exit 0

and hit submit.

All of the guides I found had different rc.local scripts. This is the only one that works.
– reboot the router, the VPN will connect, you will have internet access, check your ip at

My interfaces look like this:

What the interface page looks like

My firewall looks like this:

What the Firewall looks like


If your VPN requires a username and a password then do the following

Create a file in /etc/openvpn called pass.txt with the following contents


In your configuration file enter the following line

auth-user-pass pass.txt

Getting Openwrt to connect automatically

Recently I had issues that my ISP (ACT Broadband) would drop the connection. This meant that we had to reconnect and log on to a portal to get connected. It was quite a pain so I wrote a script to do that and had the script run every 5 min.
To get it working you first need to install wget-nossl becuase the wget that comes with openwrt does not work. To install wget run the command

opkg install wget-nossl

The script for reconnecting is

if ! ping -c 1 > /dev/null 2>&1
ifdown wan;
sleep 10;
ifup wan;
sleep 10;
wget -q -O /dev/null --post-data 'username=your_username&password=your_password&login=login' http://yourURL/;
echo "Reconnected";
echo "Fine";


Our ISP login form started taking 2 more parameters namely

p_auth (which is in the URL) and

To provide for these two parameters I had to change my code to the following:

if ! ping -c 1 > /dev/null 2>&1
ifdown wan;
sleep 10;
ifup wan;
sleep 10;
ip=`ifconfig eth0.2 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'`;
url=`wget --quiet -O - | grep "<form.*POST"| awk -F "\"" '{print $2}'`;
wget -q -O /dev/null --post-data "$postData" $url;
echo "Reconnected";
echo "Fine";