In this post, I will walk you through the process of setting up your EdgeRouterX with your OpenVPN client credentials, so that you can route all your traffic over your VPN service provider or if your hosting your own VPN server in the cloud. I’ve provided all the commands below that you can simply copy and paste after you have modified it slightly to reflect your internal subnet IP address.
Once you have basic internet connectivity, then you can proceed to the steps below.
STEP 1:
Download your OVPN file from your provider or your OpenVPN Server and copy the file to the /config/auth/ folder on the EdgeRouterX.
You should upload to: /config/auth/vpn-client.ovpn
To allow for a username/password login rather than a certificate based login, I needed to modify the OVPN file to add the following directive:
auth-user-pass /config/auth/pass.txt
Then create a file called pass.txt. On the first line is your username, and on the second line is your password. Upload this to
/config/auth/pass.txt
STEP 2:
Configure Ubiquiti EdgeRouterX
Login to your EdgeRouterX’s CLI, either via SSH or via the Web GUI. Here’s the commands you need to run:
##### Please Customize if your subnet address is different from 192.168.31.0/24 #####
set interfaces openvpn vtun0 description ‘OpenVPN Client’
set service nat rule 5000 log disable
set service nat rule 5000 outbound-interface vtun0
set service nat rule 5000 source address 192.168.31.0/24
set service nat rule 5000 type masquerade
set firewall modify openvpn_route rule 10 source address 192.168.31.0/24
set firewall modify openvpn_route rule 10 modify table 1
save
exit
STEP 3:
At this point, you should be connected, but as a best practice, i recommend that you reboot your router to ensure that everything come back up and starts up successfully.
Once your router is back up, you should now be connected to your OpenVPN server successfully and all traffic is now routed through the OpenVPN server. You can now login to the router and open the “Log Monitor” (found under tools). You should start seeing openvpn entries.
STEP 4:
That’s It!!!