Setting up an OpenVPN server with GL.iNet
Virtual Private Networks (VPNs) can be utilized for a number of very useful applications. You can securely connect to any public WiFi hotspot. You can overcome geo-blocking restrictions on your favourite websites. And you can even connect to your home or office network from anywhere in the world, as if you were sitting right at your desk. This guide will walk you through the process of setting up your own OpenVPN server, and connecting to it with your copy of Viscosity.
Running your own OpenVPN server will allow you to encrypt everything you do on the internet, so that you can safely do your online banking on the free WiFi at your favourite cafe. Anything you send over the VPN connection will be encrypted from your device until it reaches your OpenVPN server at home. Setting up your OpenVPN server to access your home or office network gives you full access to all your files on your network.
This guide will walk you through the steps involved in setting up an OpenVPN server on a GL.iNet router that allows you to securely access your home/office network from a remote location and optionally send all of your network traffic through it so you can access the internet securely as well.
Preparation
This guide assumes you have already completed the initial setup of your GL.iNet router.
- Your GL.iNet router supports OpenVPN Server and has a working internet connection
- Your client device is connected to the router's LAN and you have the password for the GL.iNet Admin Panel
- You already have a copy of Viscosity installed on your client device
For this guide we used a GL.iNet Brume 3 (GL-MT5000) running firmware 4.9.2. If you are using a different GL.iNet router with the same firmware, most of the steps should still apply. If you are looking to set up an OpenVPN server on a different operating system, please check out our other guides.
Your home or office network needs a public IP address that you can reach from the internet. If the GL.iNet router sits behind another router, forward UDP port 1194 on that router to the WAN IP address of your GL.iNet router. If your ISP uses carrier-grade NAT, ask your ISP for a public IP address. You can find more information in our Introduction to Running an OpenVPN Server.
If you don't have a copy of Viscosity already installed on your client, then please check out this setup guide for installing Viscosity (Mac | Windows).
Support
Unfortunately we cannot provide any direct support for setting up your own OpenVPN server. We provide this guide as a courtesy to help you get started with, and make the most of, your copy of Viscosity.
For further information or help with your GL.iNet router, please see the GL.iNet OpenVPN Server guide or visit the GL.iNet community forum.
Creating the OpenVPN Server
- Open a browser on your client device and navigate to the LAN IP address of your GL.iNet router. The default address is
http://192.168.8.1. Enter your Admin Password and clickLogin. -
In the sidebar, click
VPN>OpenVPN Server. The first time you open this page, clickGenerate Configuration. The router will generate the certificates and keys for you. -
In the Configuration tab, leave Device Mode set to TUN, Protocol set to UDP, and Local Port set to 1194. For this guide we'll use Certificate only for the Authentication Mode.
-
Check the IPv4 Subnet. This is the range of addresses the router will give VPN clients. You can leave it at
10.8.0.0/24unless it overlaps with your home or office LAN, or with the network you'll be connecting from. If it overlaps, choose an unused subnet and clickApply. -
To allow VPN clients to reach computers and file servers on your home or office network, click
Optionsat the top right of the OpenVPN Server page. Turn on Allow Remote Access to the LAN Subnet and clickApply.
Exporting the Client Configuration
- At the bottom of the Configuration tab, click
Export Client Configuration. -
In the Address menu, select the public IP address your client will connect to from outside your network. If your ISP changes your public IP address, you can use the
Enable DDNSlink to set up Dynamic DNS, then return here and select your DDNS hostname. -
Click
Exportand save the.ovpnfile to the Mac or Windows computer where you will use Viscosity. The file contains your client certificate and private key. Anyone with a copy can use it to connect, so keep it somewhere private. -
At the top of the OpenVPN Server page, click
Start. Once the server is running, the page will show that it is ON, along with its tunnel address and traffic statistics.
Setting Up Viscosity
The interface provided by the Mac and Windows versions of Viscosity are intentionally very similar. As such, we will focus our guide on the Mac version, pointing out any differences with the Windows version as they arise.
If you do not have Viscosity already running, start Viscosity now. In the Mac version you will see the Viscosity icon appear in the menu bar. In the Windows version you will see the Viscosity icon appear in the system tray.
Importing
-
Click the Viscosity icon in the macOS menu bar or Windows system tray and select
Settings…. In earlier versions of Viscosity this menu item is calledPreferences…. -
In Connections, click the
+button at the bottom left and selectImport Connection>From File…. -
Navigate to the
.ovpnfile you downloaded from the router, select it and clickOpen. You will see a pop up message to indicate that the connection has been imported.
(Optional) Sending Only Home or Office Traffic Through the VPN
By default, the GL.iNet server directs your IPv4 internet traffic through your home or office. If that is what you want, you can go straight to connecting. If you only want to reach devices on your home or office LAN and use your usual internet connection for other traffic, make the following changes in Viscosity.
- Double-click the connection in the Connections list to open the connection editor. In the Networking tab, set All Traffic to Automatic (Set by server).
-
In the Advanced tab, add the following on two new lines. The first line tells Viscosity to ignore the server's default route. The second sends traffic for the GL.iNet LAN through the VPN. Replace
192.168.8.0and255.255.255.0with the network address and subnet mask of your GL.iNet LAN if you have changed them.pull-filter ignore redirect-gateway route 192.168.8.0 255.255.255.0 -
Click
Save. You can find more information in our guide to Routing Traffic For Websites & Applications.
Connecting and Using Your VPN Connection
To try the connection, connect your client device to a different network, such as a phone's hotspot. This lets you test the same address you will use when you are away from home.
You are now ready to connect. Click on the Viscosity icon in the macOS menu bar or Windows system tray to open the Viscosity Menu, select the connection you imported, and Viscosity will connect.
To check that the VPN is up and running, you can open the Details window from the Viscosity Menu. This will allow you to view connection details, traffic and the OpenVPN log.
Try opening a file share or another service on your GL.iNet LAN using its local IP address. If you are sending your internet traffic through the VPN, a public IPv4 address lookup should show your home or office IP address. If your client also uses IPv6 and your VPN is IPv4-only, Viscosity can block IPv6 traffic while connected. See Preventing IPv6 Network Leaks.
That's it, you've set up your very own OpenVPN server. Congratulations, you are now free to enjoy the benefits of operating your own OpenVPN server!