Want to securely access your home or office network from anywhere? A VPN tunnel on a UniFi device can help. It keeps your data safe and lets you browse as if you’re at home. Setting it up may sound complicated, but don’t worry! We’ll walk through it step by step.
What You Need
- A UniFi Security Gateway (USG) or Dream Machine
- UniFi Controller or UniFi Network Application
- An internet connection
Let’s get started!
Step 1: Access the UniFi Controller
- Launch the UniFi Controller or log in to the UniFi Network Application.
- Go to the Settings menu.
- Find and click on VPN.
This is where the magic begins!
Step 2: Create a VPN Network
- Click Create New Network.
- Set the Purpose to Remote User VPN.
- Choose VPN Type: L2TP Server.
Your VPN is taking shape. Let’s move forward.
Step 3: Configure VPN Settings
- Set a secure Pre-Shared Key (Write this down!).
- Enter the Radius Authentication Server as 127.0.0.1.
- Activate MS-CHAP v2 for authentication.
So far, so good! Time to add some users.
Step 4: Add VPN Users
- In UniFi Settings, go to Profiles.
- Click Radius and enable the server.
- Navigate to Users and create a user.
- Set a username, password, and save.
Each user will use these credentials to connect to the VPN.
Step 5: Firewall Rules
We need to allow VPN traffic through the firewall.
- Go to Settings > Firewall & Security.
- Click on Rules and choose WAN In.
- Add a new rule for L2TP and IPSec.
- Allow traffic on ports UDP 500, UDP 4500, and ESP.
This ensures VPN connections won’t be blocked.
Step 6: Connect to the VPN
Now, let’s connect from a remote device.
On Windows:
- Open Network & Internet Settings.
- Go to VPN and click Add a new connection.
- Enter your VPN Server Address (Your public IP or domain).
- Choose L2TP/IPSec and enter the Pre-Shared Key.
- Save and click Connect.
Your Windows system should now be connected.
On Mac:
- Go to System Preferences > Network.
- Click + to add a new VPN connection.
- Select L2TP over IPSec and enter your server info.
- Enter the Pre-Shared Key.
- Click Apply and then Connect.

Step 7: Test the VPN
Everything is set up, but let’s make sure it works.
- Connect to the VPN from your remote device.
- Go to WhatIsMyIPAddress.
- If your IP matches your home network, it works!
If it doesn’t, check your firewall rules and configurations.
Bonus: Make It Even Better
Want to fine-tune your VPN?
- Use Dynamic DNS (DDNS) if you don’t have a static IP.
- Enable Split Tunneling to only route select traffic through the VPN.
- Update your firmware to avoid bugs.
Final Thoughts
That’s it! You’ve successfully set up a VPN tunnel on UniFi. Now, you can securely connect to your home or office from anywhere.

Take a moment to celebrate, then test everything again to be sure. Happy secure browsing!