VPN on Router — Openvpn on Openwrt Router

Vikas
2 min readMay 16, 2020

I was trying to enable openvpn on my router using operwrt firmware. I ran into few roadblockers so decided to document it here for reference.

Step # 1 — Flash router with openwrt official image.

  • go to URL — https://openwrt.org/toh/start
  • You will see the list of images available. Select and download the correct image based on your router model.
  • Go to Luci GUI of your router and flash the image on your router.

Step # 2 — Enable openvpn in the router.

Connect to the router using SSH and execute below commands -

  • opkg update
  • opkg install openvpn-openssl luci-app-openvpn
  • openvpn -version

Once openvpn is installed, then VPN tab will be show in the home screen of the Luci router interface.

Step # 3 — Download openvpn configuration from your vpn provider and upload to Router

  • Your VPN provider will provide the openvpn configuration file. Download the file. Along with openvpn config file, you will also get the username and password required for authentication.
  • Upload the openvpn config file here from Luci GUI

Step # 4 — Copy credentials from vpn provider. Link auth credential file location to openvpn.

  • Copy the username and password as obtained from your vpn vendor to auth.txt file in new lines.
  • Copy the file to /etc/openvpn/custom/auth.txt in router using ssh.
  • Update the file access in the openvpn configuration file — auth-user-pass /etc/openvpn/custom/auth.txt
    /etc/openvpn/custom/auth.txt

Step # 5 — Change access mode on the custom auth file.

Step # 6 — Create VPN Interface.

Step # 7 — Set the Firewall rule.

Step # 8 — Assosciate Firewall rule to VPN Interface.

Step # 9 — Complete setup and Start VPN connection.

Github Documentation

https://github.com/vikasmca05/openvpn-for-router

Originally published at https://justvikas.com on May 16, 2020.

--

--

Vikas

Hi, I m Vikas. I have studied and worked in engineering for several years now. I have proudly worked with some fantastic teams, people and brand.