setup vpn on unifi gateway

Setup VPN on UniFi Gateway: Step-by-Step Guide

By Brian Martin
AD

In the connected world we live in today, securing our digital footprint is paramount. One of the best ways to achieve this is by using a VPN, or Virtual Private Network. If you're a user of Ubiquiti's UniFi network devices, you might be wondering how to set up a VPN on your UniFi gateway. This comprehensive guide will walk you through the process, ensuring your internet traffic remains secure and private.

Before we dive into the setup process, let's briefly understand why you might want to set up a VPN on your UniFi gateway. A VPN encrypts all the data sent and received from your devices, protecting it from potential hackers and snoops. It's particularly useful when you're connecting to public Wi-Fi networks, as it shields your data from malicious actors. Additionally, a VPN can help bypass geo-restrictions, allowing you to access content that might otherwise be unavailable in your region.

Understanding Your VPN Options

Before you start the setup process, it's important to understand that there are two main types of VPNs you can set up on your UniFi gateway - OpenVPN and WireGuard. OpenVPN is a more established protocol, widely used and well-documented, while WireGuard is a newer, more modern protocol that's simplified and easier to configure. Both have their advantages, so the choice ultimately depends on your needs and preferences.

AD
How To: Deploying a Ubiquiti UniFi Home Network including Multiple WiFi Access Points (Part 1) - Free Time
How To: Deploying a Ubiquiti UniFi Home Network including Multiple WiFi Access Points (Part 1) - Free Time
UniFi Network setup
UniFi Network setup
there are many different types of electronic equipment on the shelf in front of the table
there are many different types of electronic equipment on the shelf in front of the table

In this guide, we'll focus on setting up WireGuard as it's simpler and more straightforward. However, the basic principles can be applied to setting up OpenVPN as well. If you decide to go with OpenVPN, Ubiquiti provides detailed instructions in their official documentation.

Why WireGuard?

WireGuard is often preferred over OpenVPN due to its simplicity and security. It uses modern cryptography and has a much smaller attack surface, making it less vulnerable to common VPN attacks. It's also easier to configure and manage, which can save you time and hassle in the long run.

How To Setup A VPN Step By Step: iPhone, Windows, Mac, Android & More
How To Setup A VPN Step By Step: iPhone, Windows, Mac, Android & More
How to Set Up VPN on iPhone (iOS 17)
How to Set Up VPN on iPhone (iOS 17)
Massive UniFi Home Network Upgrade - Part 2: Setup, Configuration and Performance Results
Massive UniFi Home Network Upgrade - Part 2: Setup, Configuration and Performance Results

Additionally, WireGuard is stateful, meaning it only needs to keep track of active connections. This makes it more efficient and reduces the risk of connection issues. It's also more battery-efficient, making it a great choice for mobile devices.

Requirements for Setting Up WireGuard on UniFi Gateway

Before you start the setup process, ensure you have the following ready:

AD
  • Access to your UniFi controller
  • UniFi devices that support VPN - this includes the USG (UniFi Security Gateway) and the UXG-Pro (UniFi XG Professional)

Once you have these, you're ready to set up your WireGuard VPN.

You don't need a VPN app: how Windows 11 already handles it
You don't need a VPN app: how Windows 11 already handles it
πŸ”’ Basic Site-to-Multi-Site VPN (Hub-and-Spoke) Topology Need to securely connect multiple branch offices to your Head Office or Data Center? A Hub-and-Spoke Site-to-Site VPN is one of the most common enterprise designs for secure and scalable connectivity. In this topology: βœ… A central Hub (Head Office) establishes encrypted IPsec VPN tunnels with multiple branch offices (Spokes). βœ… Each branch maintains its own local LAN while securely accessing resources at the Head Office. βœ… All communic... Computer Knowledge, Data Center
πŸ”’ Basic Site-to-Multi-Site VPN (Hub-and-Spoke) Topology Need to securely connect multiple branch offices to your Head Office or Data Center? A Hub-and-Spoke Site-to-Site VPN is one of the most common enterprise designs for secure and scalable connectivity. In this topology: βœ… A central Hub (Head Office) establishes encrypted IPsec VPN tunnels with multiple branch offices (Spokes). βœ… Each branch maintains its own local LAN while securely accessing resources at the Head Office. βœ… All communic... Computer Knowledge, Data Center
the dashboard screen for an app showing different devices and their features, including wifi
the dashboard screen for an app showing different devices and their features, including wifi
My Homelab Setup
My Homelab Setup
2022 Complete Unifi Setup Guide
2022 Complete Unifi Setup Guide
How to Set Up OpenVPN on pfSense (Server/Client)
How to Set Up OpenVPN on pfSense (Server/Client)

Setting Up WireGuard on Your UniFi Gateway

The first step in setting up WireGuard is to enable it on your UniFi gateway. This process is straightforward and can be done through the UniFi controller.

critica!!! STARTING wifirules! Enable WireGuard on Your UniFi Gateway 1. Log in to your UniFi controller. 2. Navigate to the 'Settings' tab. 3. Under the 'Advanced' section, click on 'Site-wide VPN'. 4. Select 'Enable' next to 'WireGuard'. 5. Give your VPN a name and click 'Save'.

AD

Configuring WireGuard Settings

After enabling WireGuard, you'll need to configure its settings. This involves setting up encryption and hashing parameters, as well as allocating IP addresses for your devices. Here's how:

2021 Complete Unifi Setup Guide
2021 Complete Unifi Setup Guide
How to Use a VPN on a MacBook: Complete Setup Guide 2025
How to Use a VPN on a MacBook: Complete Setup Guide 2025
Why do I have to use Nord VPN?
Why do I have to use Nord VPN?
Dual-router setup w/ a dedicated VPN Router: A step-by-step tutorial
Dual-router setup w/ a dedicated VPN Router: A step-by-step tutorial
Windows 10: Network & Internet settings explained - Pureinfotech
Windows 10: Network & Internet settings explained - Pureinfotech
How to Choose a VPN
How to Choose a VPN
Build a Safer UniFi Setup with VLANs, Zone-Based Firewalls, and Smart mDNS Rules
Build a Safer UniFi Setup with VLANs, Zone-Based Firewalls, and Smart mDNS Rules
πŸ” Types of VPN Explained – A Complete Hierarchy! 🌐 VPNs are more than just secure remote access. They come in different types, each designed for specific networking needsβ€”from connecting branch offices to enabling secure remote users and service provider networks. πŸ’‘ Key VPN Categories: 🏒 Site-to-Site VPN – Securely connects offices across different locations. πŸ’» Remote Access VPN – Allows users to safely access corporate resources from anywhere. 🌍 Provider-Provisioned VPN (PPVPN) – Managed ...
πŸ” Types of VPN Explained – A Complete Hierarchy! 🌐 VPNs are more than just secure remote access. They come in different types, each designed for specific networking needsβ€”from connecting branch offices to enabling secure remote users and service provider networks. πŸ’‘ Key VPN Categories: 🏒 Site-to-Site VPN – Securely connects offices across different locations. πŸ’» Remote Access VPN – Allows users to safely access corporate resources from anywhere. 🌍 Provider-Provisioned VPN (PPVPN) – Managed ...

1. In the 'Site-wide VPN' settings, scroll down to the WireGuard section.

2. Under 'Private Key', you'll see a string of text beginning with 'ubnt@wireguard'. This is your private key. It's crucial that you keep this private and secure. You'll need it to configure your WireGuard clients (the devices that will connect to your VPN).

AD

3. In the 'Allowed IPs', enter the IP range that your devices will use when connected to the VPN. For example, you might set this to '10.10.0.0/16', which would allocate IP addresses from 10.10.0.0 to 10.10.255.255 for your devices.

4. In the 'Interface Address', enter the IP address and netmask for your WireGuard interface. This will typically be something like '10.10.0.1/24'.

Understanding these settings can be a bit technical, but they're crucial for ensuring your VPN is secure and functioning correctly. If you're unsure about any of these, it's a good idea to consult with a network professional.

Adding WireGuard peers (clients)

Once your WireGuard server is set up, you'll need to add peers (or clients) to it. These are the devices that will connect to your VPN. This can be done manually, but Ubiquiti provides a more convenient option - the 'Generate QR Code' feature.

1. In the 'WireGuard peers' section, click on 'Generate QR Code'.

2. A QR code will be generated, which you can scan with your WireGuard client devices to automatically configure them. This is particularly useful if you're setting up WireGuard on a mobile device, as it can significantly simplify the process.

Testing Your WireGuard VPN

With your WireGuard server set up and peers added, it's time to test your VPN to ensure everything is working correctly. Here's how:

1. Connect your device to the VPN using either the manual settings or the QR code.

2. Once connected, open a web browser and visit a website that shows your IP address. A quick Google search should turn up several options. Your IP address should now be that of your VPN server, not your actual IP address. This is a sign that your VPN is working correctly.

3. If everything is working as expected, congratulations! You've successfully set up a WireGuard VPN on your UniFi gateway. Your internet traffic is now encrypted and secure.

Remember, setting up a VPN is just the first step in securing your digital footprint. Regularly updating your device's software, using strong passwords, and being cautious online are all important aspects of digital security. Enjoy your secure browsing!

AD