OpenVPN on Ubiquity EdgeRouter

This guide was created using an EdgeRouter X running EdgeOSv1.9.7+hotfix.2
  1. login on the EdgeRouter device through SSH
  2. switch to root, create the openvpn foloder within /config, download a server profile from our repository:

    sudo -i  
    cd /config  
    mkdir openvpn  
    cd openvpn  
    curl -O https://vpn.ac/ovpn/AES-128-UDP/germany-aes128-udp.ovpn  
    
  3. add your VPN username and password to a txt file:

echo -e "vpnusername\nvpnpassword" > auth.txt

Note: the VPN username and the VPN password are separated by the "\n" (new line separator), it is essential to include it. For example, for VPN username vpn123456 and VPN password "s3cr3t", run: echo -e "vpn123456\ns3cr3t" > auth.txt

  1. change .ovpn file to point to the authentication file:

sed -i 's,auth-user-pass,auth-user-pass /config/openvpn/auth.txt,g' *.ovpn

  1. enable OpenVPN:

    configure  
    set interfaces openvpn vtun0 config-file /config/openvpn/romania-aes128-udp.ovpn  
    commit  
    save  
    

Note: the correct name of the .ovpn file name must be provided, depending on what location you want to connect to.

  1. Open your Edgerouter's web admin interface > Firewall/NAT > NAT > + Add Source NAT Rule

For rule name choose "openvpn", Outbound interface: select vtun0, check Use Masquerade

Save the rule. VPN should now be connected and all your traffic should go through the VPN.

To disable the OpenVPN connection, open the EdgeRouter's web interface and in the Dashboard tab find the "vtun0" interface in the list, click op Actions button and Disable it.
To re-enable the OpenVPN connection, enable the vtun0 interface in the same tab.

To disable OpenVPN completely, run through SSH (as root):

configure
delete interfaces openvpn vtun0
commit
save

Other tutorials: