How to Set Up a WireGuard Server on OPNsense
A step-by-step technical guide for home lab and small business admins to deploy a WireGuard VPN server on OPNsense 25.7.6, including plugin installation, interface assignments, firewall tuning, and network best practices.
1. Introduction
When I built my OPNsense network, the next logical step was secure remote access. WireGuard provided the best balance of performance, simplicity, and security.
This guide covers how to install and configure a WireGuard VPN server on OPNsense 25.7.6, manage firewall rules, and understand how domain vs. IP endpoint configurations affect stability.
2. Installing the WireGuard Plugin
-
Ensure OPNsense is updated to the latest patch level:
System → Firmware → Updates → Check for updates -
Once updated, install the WireGuard plugin:
System → Firmware → Plugins → os-wireguard -
After installation, reboot OPNsense. The WireGuard menu will appear under:
VPN → WireGuard
3. Creating the WireGuard Server Instance
-
Go to VPN → WireGuard → Instances and click Add.
-
Configure as follows:
| Setting | Value | Description |
|---|---|---|
| Name | Main |
Name of the server instance |
| Listen Port | 51820 |
Default WireGuard UDP port |
| Interface Keys | Generate new keys | Automatically creates private/public pair |
| Tunnel Address | 10.10.0.1/24 |
Internal WireGuard subnet |
| Peers | Leave empty | Peers added later |
- Enable the instance and click Apply to finalize.
4. Assigning and Configuring the Interface
When you create a WireGuard instance, OPNsense automatically generates a virtual interface (e.g., wg0).
- Go to Interfaces → Assignments.
- Add a new interface and select wg0.
- Rename it to WG_Main.
- Enable the interface and assign the IP
10.10.0.1/24.
This ensures WireGuard behaves like a physical interface, allowing you to apply firewall rules, NAT, and monitoring.
5. Adding a Peer (Client)
- Navigate to VPN → WireGuard → Peer generator. This creates an entry for a single client device that connects to your server.
| Field | Example Value | Description |
|---|---|---|
| Instance | Main |
The WireGuard instance to associate with |
| Endpoint | vpn.example.net:51820 |
Your WAN domain or IP |
| Name | Laptop |
Friendly identifier |
| Address | 10.10.0.2/32 |
Peer IP within WG subnet (generated automatically) |
| Allowed IPs | 0.0.0.0/0,::/0 |
IPs subnets that will go through the VPN on the client |
Each peer must have a unique IP within the WireGuard network. The Allowed IPs field is very useful if you want to split-tunnel your connection.
For example, if you only need VPN access to internal resources, set Allowed IPs to 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
With this configuration, traffic to public IP ranges (i.e., the internet) will bypass the VPN entirely. This approach reduces latency and improves performance since only traffic destined for your private networks is routed through the tunnel.
6. Domain vs. IP Endpoint — Which to Use
You can either use your public IP or a domain name for remote access:
| Option | Example | Pros | Cons |
|---|---|---|---|
| Domain | vpn.mydomain.com |
Works with dynamic IPs, easier to remember | Requires DNS or DDNS |
| Static IP | 203.0.113.45 |
Simple if you have a fixed IP | Breaks if WAN IP changes |
If your ISP assigns dynamic IPs, configure Dynamic DNS directly on OPNsense (os-ddclient plugin) under Services → Dynamic DNS.
Providers like Cloudflare, GoDaddy, or DuckDNS make this simple.
In my setup, I use a static IP, but DuckDNS is a good free alternative if you don’t own a domain.
7. Creating an Alias for WireGuard Ports
If you plan to host multiple WireGuard instances (like a management tunnel or a separate access profile), create a port alias.
- Go to Firewall → Aliases → Add.
- Name it
WG_PORTS. - Type:
Port(s). - Enter:
51820. - Description:
WireGuard Ports. - Save and apply.
Then, if you want to run more than one WireGuard server, just add more ports to this alias. This automatically updates the WAN rule without needing to edit it manually.
8. Configuring Firewall Rules
WireGuard won’t function until the firewall allows inbound traffic and defines what connected clients can access.
Step 1 — Open the WireGuard Port on WAN
- Go to Firewall → Rules → WAN → Add.
- Configure as follows:
| Option | Value |
|---|---|
| Action | Pass |
| Interface | WAN |
| Protocol | UDP |
| Source | Any |
| Destination | This Firewall |
| Destination Port | WG_PORTS (alias for 51820, etc.) |
| Description | Allow WireGuard to OPNsense |
This rule permits WireGuard traffic from the internet to reach your OPNsense firewall.
Step 2 — Allow Traffic on the WireGuard Interface
- Go to Firewall → Rules → WG_Main → Add.
- Configure as follows:
| Option | Value |
|---|---|
| Action | Pass |
| Interface | WG_Main |
| Protocol | Any |
| Source | WG_Main network |
| Destination | Internal VLANs (10, 15, etc.) |
| Description | Allow WireGuard clients to LAN/VLANs |
This rule defines what remote clients can access inside your network. You can restrict access to specific VLANs or services depending on your security needs.
9. Restricting VPN Client Access
To prevent WireGuard clients from accessing sensitive subnets (like management VLANs), add targeted firewall rules on WG_Main.
| Priority | Action | Source | Destination | Description |
|---|---|---|---|---|
| 1 | Pass | 10.10.0.0/24 |
192.168.10.0/24 |
Allow access to Trusted VLAN |
| 2 | Block | 10.10.0.0/24 |
192.168.5.0/24 |
Block Management VLAN |
| 3 | Pass | 10.10.0.0/24 |
* |
Allow Internet (via NAT) |
This approach ensures WireGuard users can only reach designated networks while maintaining isolation for administrative segments.
10. Creating an Alias for WireGuard Networks
If you plan to manage multiple WireGuard tunnels (for example, wg0 for main access and wg1 for management), create a network alias to simplify rules.
- Go to Firewall → Aliases → Add.
- Name it
WG_Networks. - Type:
Network(s). - Enter:
10.10.0.0/24 - Description:
WireGuard Networks. - Save and apply.
This alias groups all WireGuard subnets into a single reference, making it easier to manage multiple instances. It’s especially useful for NAT and firewall rules, allowing consistent policies across all VPN tunnels.
For example, when creating the NAT rule below, use WG_Networks instead of specifying a single subnet. If you later deploy another WireGuard server, simply add its subnet to this alias—your existing rules will automatically apply to it.
11. Outbound NAT and Internet Access
To allow VPN clients to reach the internet through OPNsense:
- Go to Firewall → NAT → Outbound.
- Select Hybrid Outbound NAT.
- Add a rule:
- Interface: WAN
- Source:
WG_Networks - Translation: Interface Address
- Description: NAT WireGuard clients
Without this rule, clients can connect but won’t reach the internet.
This setup ensures any WireGuard subnet listed in your WG_Networks alias can route outbound properly.
12. Testing and Verification
After applying all rules:
- Connect your client (Windows, Linux, macOS, Android, etc.).
- On OPNsense, go to VPN → WireGuard → Status and confirm a successful handshake.
- If traffic fails, check:
- Outbound NAT rules
- WG_Main interface rules
- WAN UDP port access
| Symptom | Likely Cause |
|---|---|
| No handshake | UDP 51820 not open on WAN |
| Handshake, no traffic | Missing outbound NAT or blocked rule |
| Unstable connection | CGNAT or ISP UDP filtering |
13. Final Thoughts
WireGuard’s native integration in OPNsense makes it an excellent choice for efficient, secure remote access. It runs well on low-power hardware and scales cleanly using aliases and VLAN-based rule separation.
For reference, review how VLANs and firewall isolation are structured in my related post: How I Built My Segmented OPNsense and UniFi Network