Ubiquiti edge router vpn setup: how to configure site-to-site and client-to-site VPN on EdgeRouter X/ER‑4/ER‑6, with IPsec, OpenVPN, and WireGuard options
Yes, you can set up a VPN on Ubiquiti EdgeRouter. This guide covers the practical, real‑world steps to get VPNs running on EdgeRouter devices, including site‑to‑site IPsec, client‑to‑site configurations using L2TP/IPsec, and notes on OpenVPN and WireGuard options. You’ll get a solid walkthrough from prerequisites to testing, plus troubleshooting tips, optimization ideas, and security best practices. Whether you’re connecting a remote office, protecting traffic from your smart home, or just tunneling a few devices through a privacy‑minded VPN, this post has you covered with clear steps and concrete examples.
Psst: for extra privacy while you work through the setup, you might want to pair your EdgeRouter with a trusted VPN service. NordVPN is a popular option and can help encrypt traffic from devices behind your router. 
Useful resources to keep handy while you read:
– Ubiquiti official EdgeRouter documentation – docs.ui.com
– EdgeOS user guide and CLI references – help.ui.com
– OpenVPN project – openvpn.net
– WireGuard project – www.wireguard.com
– NordVPN – nordvpn.com
– Community forums for EdgeRouter tips – community.ubiquiti.com
Why you’d want a VPN on an EdgeRouter
EdgeRouter devices run EdgeOS, a VyOS‑like Linux-based router OS that shines when you want granular control over routing, firewall rules, and VPN connections. A VPN on your EdgeRouter helps you:
- Protect traffic leaving your network when you’re using public Wi‑Fi or remote sites
- Connect two or more office networks securely site‑to‑site
- Provide client access to a private network without exposing devices directly to the Internet
- Route specific subnets through a VPN while keeping other traffic local split tunneling
A few quick notes before we dive in:
- EdgeRouter’s VPN options are powerful but can be a little more manual than consumer VPN routers. If you’re new to EdgeOS, be prepared to copy, paste, and tweak command blocks.
- The exact UI labels can vary a bit by firmware version, so if you don’t see a field exactly named the same, look for the same concept Phase 1 settings, Phase 2, local/remote networks, etc..
Prerequisites
Before you touch the VPN settings, gather these basics:
- EdgeRouter model and firmware version e.g., EdgeRouter X, ER‑4, ER‑6, or higher and access to EdgeOS GUI or SSH
- Your WAN interface name for example eth0 and the internal LAN subnet for example 192.168.1.0/24
- The VPN topology you want: site‑to‑site two networks linked via VPN or client‑to‑site a remote client or net behind a VPN gateway
- Remote endpoint details for IPsec remote public IP, remote LAN subnet, encryption/authentication methods, and a pre‑shared key
- If using L2TP/IPsec or OpenVPN, credentials and the server address or provider endpoints
- A plan for firewall rules to ensure VPN traffic is allowed while staying secure
- Optional: a spare device on your network to test connectivity via a VPN gateway if you’re going with a more complex topology
Tip: Do a quick firmware check and backup your current EdgeRouter config before you start messing with VPN rules. It’s a lot easier to recover if you have a working backup.
VPN topology options on EdgeRouter
Here are the most common patterns you’ll implement: Edgerouter x site to site vpn
- Site‑to‑site IPsec VPN: Connects two or more networks directly. Each site has a VPN tunnel, and the two LANs can talk as if they’re on the same network.
- Client‑to‑site VPN remote access: Lets individual users or devices connect to your network from outside via IPsec/L2TP or OpenVPN.
- OpenVPN client on EdgeRouter: Some EdgeRouter firmware versions support running an OpenVPN client or server. in many cases, people run OpenVPN on a dedicated device behind the EdgeRouter and route traffic accordingly.
- WireGuard: Native WireGuard support on EdgeRouter is not universally present across all firmware versions. If your version supports it, you can set up a lightweight, fast tunnel. otherwise, consider a separate gateway on your LAN or stick with IPsec.
In the rest of this guide, you’ll see practical templates for IPsec site‑to‑site and L2TP/IPsec client‑to‑site, plus notes on OpenVPN and WireGuard so you know what to do if your project calls for them.
IPsec Site-to-Site VPN on EdgeRouter example template
This is the bread‑and‑butter for linking two offices. You’ll configure a Phase 1 IKE and Phase 2 IPsec tunnel, define the networks on each end, and ensure traffic passes through the VPN.
What you’ll need:
- Remote peer IP address public
- Local networks on your EdgeRouter side e.g., 192.168.1.0/24
- Remote networks on the other side e.g., 10.0.0.0/24
- Pre-shared key PSK or a certificate method if you’re using certificate‑based authentication
Example CLI configuration replace placeholders with your values:
set vpn ipsec ipsec-interfaces interface eth0
# Phase 1: IKE
set vpn ipsec ike-group IKE-GROUP0 proposal 1 encryption aes128
set vpn ipsec ike-group IKE-GROUP0 proposal 1 sha2
set vpn ipsec ike-group IKE-GROUP0 proposal 1 group 2
set vpn ipsec ike-group IKE-GROUP0 proposal 1 lifetime 3600
# Phase 2: IPsec
set vpn ipsec esp-group ESP-GROUP0 proposal 1 encryption aes128
set vpn ipsec esp-group ESP-GROUP0 proposal 1 sha2
set vpn ipsec esp-group ESP-GROUP0 proposal 1 lifetime 3600
# Peer remote gateway
set vpn ipsec site-to-site peer 203.0.113.1 authentication mode pre-shared-secret
set vpn ipsec site-to-site peer 203.0.113.1 authentication pre-shared-secret 'yourPSKhere'
set vpn ipsec site-to-site peer 203.0.113.1 ike-group IKE-GROUP0
set vpn ipsec site-to-site peer 203.0.113.1 esp-group ESP-GROUP0
set vpn ipsec site-to-site peer 203.0.113.1 local-address 198.51.100.2
set vpn ipsec site-to-site peer 203.0.113.1 tunnel 1 local prefix 192.168.1.0/24
set vpn ipsec site-to-site peer 203.0.113.1 tunnel 1 remote prefix 10.0.0.0/24
# Optional NAT exemption so VPN traffic isn't NATed
set vpn ipsec nat-networks allowed-network 192.168.1.0/24
set vpn ipsec nat-networks allowed-network 10.0.0.0/24
# Ensure VPN traffic is routed through the VPN
set protocols static route 10.0.0.0/24 next-hop via 192.168.1.1
Notes:
- The exact names of groups IKE-GROUP0, ESP-GROUP0 and the numbers you pick can vary. some firmware defaults will use different identifiers. The essential bits are: phase 1 + phase 2 parameters, the remote peer, PSK, and the local/remote subnets.
- If your partner uses certificate authentication, you’ll replace the PSK line with certificate configuration.
Testing and verification:
- Check the status with: show vpn ipsec sa
- Test connectivity by pinging a host on the remote network from a device behind your EdgeRouter
- Look at logs for troubleshooting: show log vpn, show log disk | grep ipsec
Troubleshooting tips:
- Double‑check the PSK and the remote IP address. A single character mismatch is a common fail.
- Ensure both sides’ Phase 1 and Phase 2 proposals match encryption, hash, DH group, lifetimes.
- Confirm that firewall rules allow ESP ipsec, UDP 500 ISAKMP, and UDP 4500 NAT‑T if NAT is involved.
Client‑to‑Site VPN on EdgeRouter L2TP/IPsec and OpenVPN notes
Client‑to‑site VPN is great for remote workers. EdgeRouter can do IPsec client functionality or L2TP over IPsec. OpenVPN integration is more variable and often depends on firmware version. Here are practical approaches you can adapt.
Option A: L2TP/IPsec remote access if supported by your EdgeRouter firmware
- Set up an L2TP server on EdgeRouter and enable IPsec with a PSK
- Create user credentials for remote clients
- Configure the EdgeRouter to pool IPs for remote clients and provide DNS settings
- On client devices, configure L2TP/IPsec with the PSK and the EdgeRouter’s public IP
CLI example conceptual:
set vpn l2tp remote-access authentication mode local
set vpn l2tp remote-access authentication local-users username 'user1' password 'user1password'
set vpn l2tp remote-access ipsec-options 'aes128-sha256'
set vpn l2tp remote-access ipsec enable
set vpn l2tp remote-access dns-servers '8.8.8.8'
set vpn l2tp remote-access client-ip-pool start 192.168.50.10
- The exact commands can vary by EdgeOS version. If your firmware lacks a robust L2TP remote‑access module, you might use an OpenVPN server on a dedicated device or host behind the EdgeRouter.
Option B: OpenVPN as a gateway behind EdgeRouter
- If your EdgeRouter firmware doesn’t natively run OpenVPN the way you want, run an OpenVPN server on a small PC, NAS, or Raspberry Pi behind the EdgeRouter.
- Route VPN client traffic through the EdgeRouter, creating a separate VPN gateway subnet and static routes to ensure traffic lands on the VPN gateway.
OpenVPN gateway approach high level:
- Install and configure OpenVPN server on a dedicated device in your LAN
- Create client profiles and push routes to the EdgeRouter
- Add static routes to send traffic destined for remote networks to the OpenVPN gateway
- Ensure firewall rules permit VPN traffic to the gateway and allow the return path
OpenVPN client on EdgeRouter if supported by your firmware
- Some EdgeRouter versions support an OpenVPN client in the UI or via CLI. If yours does, you’ll:
- Upload a .ovpn profile
- Set the remote server address, CA certificate, client cert/key if needed
- Route desired subnets through the VPN
- If you’re unsure, check the official EdgeRouter docs for your firmware version.
Notes on WireGuard:
- WireGuard is loved for speed and simplicity, but EdgeRouter support varies by firmware. If your EdgeRouter OS includes WireGuard, you can configure a wg0 interface, peers, and allowed IPs similarly to other basic VPN setups. If not, consider running WireGuard on a dedicated gateway within your network and route through it.
Testing and validation:
- For L2TP/IPsec, confirm that clients can connect and obtain a VPN IP from the pool
- For OpenVPN behind EdgeRouter, test client connections and verify routes to remote networks
- For all setups, ping remote hosts, check traceroutes, and review the VPN tunnel status in the EdgeRouter UI or via CLI
Troubleshooting notes:
- For any VPN, ensure your firewall rules on EdgeRouter aren’t blocking VPN control traffic ISAKMP, ESP, UDP 500/4500
- Confirm the remote network reachability and that static routes reflect the VPN topology
- If you’re using a separate VPN gateway, ensure that traffic to the VPN network uses the gateway as the next hop
WireGuard on EdgeRouter and alternatives
WireGuard is a modern VPN with excellent performance, but not all EdgeRouter firmware includes native WireGuard support. If your firmware supports it, you can set up a wg0 interface with a private key, a peer public key, an endpoint, and allowed IPs. If your EdgeRouter doesn’t offer WireGuard, you have two solid options:
- Run WireGuard on a dedicated gateway inside your network for example, a small Linux box or Raspberry Pi and route traffic from the EdgeRouter to that gateway
- Use IPsec/L2TP as your main VPN method, which is widely supported by many devices and VPN providers
Performance tip: If you do run a separate WireGuard gateway, use static routes on EdgeRouter to send VPN-bound traffic to that gateway for the desired networks. This keeps your routing clean and avoids accidental leakage.
Security note: Always keep firmware updated. VPNs are effective, but old firmware can have exploitable weaknesses or misconfigurations. A regular update cadence plus a quick audit of firewall rules goes a long way.
Testing, validation, and monitoring
- Start simple: verify your local Internet connectivity works as expected, then test VPN connectivity
- For IPsec: monitor sa security associations status with show vpn ipsec sa and check log messages around tunnel up events
- Test reachability by pinging devices on the remote network or by using traceroute to confirm that traffic is taking the VPN path
- If you’re routing only specific subnets through the VPN, confirm those routes exist in the routing table and that non‑VPN traffic uses the regular Internet path when appropriate
- Consider setting up a basic uptime/health alert for the VPN tunnel so you’re notified if a tunnel drops
Performance considerations on EdgeRouter VPNs
- CPU and hardware: VPN processing adds load. If you’re on a lower‑end EdgeRouter like ER‑X, plan for possible throughput reductions when the VPN is active
- Offloading and MTU: Ensure you’re not pushing a chain of large packets that can cause fragmentation. Adjust MTU if you see cryptic packet loss
- Split tunneling: If you don’t need all traffic to go through the VPN, implement selective routing to limit the VPN workload and improve performance
- QoS and firewall rules: Keep firewall rules lean and avoid overly broad NAT rules that complicate VPN traffic
Quick tip: Before deploying to production, test with your typical workloads file transfers, remote desktop, video calls to understand the real‑world impact and adjust MTU, encryption settings, and routing accordingly.
Security best practices for EdgeRouter VPNs
- Use strong authentication: choose robust pre‑shared keys or, if possible, certificate-based authentication for IPsec
- Limit exposure: only expose the necessary networks behind your EdgeRouter to the VPN. drop unnecessary ports to the VPN gateway from the Internet
- Regular updates: apply firmware updates to EdgeRouter devices as soon as they’re released
- Audit firewall rules: keep a clean default deny posture and add only the rules you need for VPN traffic
- Monitor logs: keep an eye on VPN status messages and look for unusual activity in EdgeRouter logs
Common pitfalls and quick fixes
- Mismatched Phase 1/Phase 2 settings: double‑check encryption, hash, and DH groups on both ends
- Incorrect local/remote subnet definitions: ensure the correct networks are defined on each side of the tunnel
- NAT issues: if VPN traffic is being NATed in unintended ways, adjust NAT rules or use NAT‑exempt rules for VPN traffic
- Client connectivity problems: verify that client devices have routes to the VPN subnet and that there are no conflicting local routes
- Firewall blocks: if VPN tunnels aren’t coming up, check your firewall rules to ensure VPN control traffic is allowed
Frequently Asked Questions
# How do I know if my EdgeRouter supports IPsec?
EdgeRouter devices have built‑in IPsec support in EdgeOS. You can configure IPsec VPNs via the GUI or CLI. If you’re unsure, check your firmware release notes or the EdgeOS documentation for IPsec features.
# Can I use NordVPN directly on EdgeRouter?
Some users run VPNs through edge devices using provider configurations, but most consumer VPN services don’t offer a native, always‑on EdgeRouter client. A common approach is to run a VPN client on a dedicated gateway device behind the EdgeRouter or to use IPsec/L2TP with a provider if supported. The NordVPN promo we included is for adding an extra layer of privacy for devices behind the router.
# Is WireGuard available on all EdgeRouter models?
Not universally. WireGuard support depends on firmware version and model. If your firmware doesn’t natively support WireGuard, use IPsec or a separate WireGuard gateway behind the EdgeRouter.
# What’s the difference between site‑to‑site and remote access VPN?
Site‑to‑site VPN connects whole networks two LANs so devices on one side can reach devices on the other as if they’re local. Remote access client‑to‑site VPN allows individual users or devices to securely connect to the private network from outside.
# Can I run an OpenVPN server on EdgeRouter?
OpenVPN server support on EdgeRouter varies by firmware. Some versions include a built‑in option. others require an OpenVPN server on a connected device in your LAN. If you need OpenVPN specifically, consider a dedicated gateway behind EdgeRouter or a router that offers straightforward OpenVPN integration.
# How do I verify my VPN tunnel is active?
Use show vpn ipsec sa to see active security associations, and check the EdgeRouter logs for “tunnel up” status messages. On the GUI, you’ll often see a tunnel status indicator. keep an eye on it after you make changes.
# How can I route only certain subnets through the VPN?
You’ll configure static routes that point to the VPN interface for the subnets you want to route through the tunnel and use non‑VPN routes for other traffic. In EdgeRouter, you’ll set up policy routing or specific static routes tied to the VPN tunnel’s interface.
# What should I do if the VPN tunnel keeps dropping?
Check for: 1 consistent remote peer availability, 2 correct PSK or certificate, 3 matching Phase 1/Phase 2 parameters, 4 firewall rules allowing necessary IPsec ports, and 5 firmware stability. Sometimes a reboot or re‑creating the tunnel can fix intermittent drops.
# Is it better to use a dedicated VPN gateway behind EdgeRouter?
For flexibility and performance, a dedicated VPN gateway can be a clean solution, especially if you want WireGuard or OpenVPN in more complex topologies. It also isolates VPN traffic from EdgeRouter’s other duties, making management easier.
# How often should I back up EdgeRouter VPN configurations?
As you’d expect, back up before making major changes and after any successful VPN deployment. Keep a separate backup of both the running configuration and a copy of the VPN key material safely stored.
Final notes
Setting up a VPN on an EdgeRouter gives you powerful control over how traffic moves between sites, devices, and the wider Internet. If you’re starting out, begin with a simple site‑to‑site IPsec tunnel and verify end‑to‑end reachability. As you gain confidence, you can add client‑to‑site access, split tunneling rules, and more advanced routing scenarios. Always test in a controlled environment first, document your settings, and keep firmware up to date.
If you found this guide helpful, share it with a friend who’s setting up a small office or a smart home network. And don’t forget to check out NordVPN using the banner above if you want an extra privacy layer while you learn and configure your VPN environment.
蜗牛vpn 使用评测与购买指南:速度、隐私保护、跨平台支持、价格与性价比、以及替代方案