An OPNsense WireGuard site-to-site tunnel can let Site A’s trusted clients open Site B’s NAS over HTTPS. Route the two trusted subnets through WireGuard, allow only the NAS connection across the tunnel, and block IoT access to the internal networks. Each site keeps its own WAN for internet traffic.
If you’re still choosing a protocol, see WireGuard vs OpenVPN vs IPsec on OPNsense.
Topology
At each site, connect the OPNsense LAN-side port to port 1 of a managed switch such as the UniFi Pro 24 PoE. Connect the access point to port 2. Each OPNsense WAN connects to its local ISP.
Use tagged VLANs 1 and 20 on the OPNsense uplink. On port 2, use untagged VLAN 1 for AP management and tag VLAN 20 for the IoT SSID. Use untagged access ports 3 and 4 for VLANs 1 and 20, respectively. OPNsense VLAN setup guide.
VLAN plan
Use five non-overlapping subnets in this example. The two trusted subnets and the WireGuard transfer subnet must also avoid overlapping networks already routed at either site. The VLAN IDs can repeat because WireGuard routes between IP networks. OPNsense’s site-to-site guide and routing table guide.
| Site and network | VLAN | Example subnet | Example DHCP range | Local gateway |
|---|---|---|---|---|
| A trusted | 1 | 10.10.10.0/24 | 10.10.10.100–10.10.10.199 | 10.10.10.1 |
| A IoT | 20 | 10.10.20.0/24 | 10.10.20.100–10.10.20.199 | 10.10.20.1 |
| B trusted | 1 | 10.20.10.0/24 | 10.20.10.100–10.20.10.199 | 10.20.10.1 |
| B IoT | 20 | 10.20.20.0/24 | 10.20.20.100–10.20.20.199 | 10.20.20.1 |
Give the NAS the fixed address 10.20.10.20 and default gateway 10.20.10.1. The transfer subnet 10.2.2.0/24 uses the two static instance addresses below. This example uses IPv4. If you also route IPv6 between sites or VLANs, apply equivalent IPv6 filtering. OPNsense’s dual-stack setup note.
Configure instances, peers and routes
Each OPNsense firewall acts as a WireGuard VPN gateway. Its WireGuard instance listens as a server and can also initiate a connection to the other site. WireGuard moved into OPNsense core in 24.1. OPNsense VPN reference and 24.1 release notes.
Start with two reachable public IPv4 WANs. Under VPN → WireGuard → Instances, add an instance on each firewall and turn on advanced mode. Use the gear button to generate a separate keypair on each instance. Save and apply, and copy only the public key to the other site. OPNsense site-to-site guide, 26.7.10 menu and 26.7.10 instance form.
| Instance field | Site A | Site B |
|---|---|---|
| Enabled | Checked | Checked |
| Name | wg-site-a | wg-site-b |
| Public and private keys | Generate a local keypair | Generate a separate local keypair |
| Listen port | 51820 | 51820 |
| Tunnel address | 10.2.2.1/24 | 10.2.2.2/24 |
| MTU | 1420, or 1412 on PPPoE | 1420, or 1412 on PPPoE |
| DNS servers | Blank | Blank |
| Disable routes | Unchecked | Unchecked |
Under VPN → WireGuard → Peers, add the opposite site and attach it using the peer’s Instances field. Save and apply. Leave global activation until the firewall rules are in place. 26.7.10 menu and 26.7.10 peer form.
| Peer field | On Site A | On Site B |
|---|---|---|
| Enabled | Checked | Checked |
| Name | peer-b | peer-a |
| Public key | B’s instance public key | A’s instance public key |
| Pre-shared key | Blank | Blank |
| Allowed IPs | 10.2.2.2/32, 10.20.10.0/24 | 10.2.2.1/32, 10.10.10.0/24 |
| Endpoint address | B’s public WAN IPv4 | A’s public WAN IPv4 |
| Endpoint port | 51820 | 51820 |
| Instances | wg-site-a | wg-site-b |
After activation, open System → Routes → Status. A should show 10.20.10.0/24 through its WireGuard interface and B should show 10.10.10.0/24 through its WireGuard interface. Both have 10.2.2.0/24 on the tunnel. OPNsense installs the remote LAN routes from Allowed IPs. Keep the default route on each site’s WAN. OPNsense VPN reference and routing table guide.
Allowed IPs determines which peer gets outbound packets and which source addresses it may send back. Leave both IoT subnets and 0.0.0.0/0 out. Check Firewall → NAT → Source NAT (Outbound) for rules that translate traffic between the trusted LANs. Keep normal WAN NAT and preserve the original LAN addresses inside the tunnel. WireGuard manual and OPNsense NAT reference.
Firewall rules
Under Firewall → Aliases, create a network alias called INTERNALS on each firewall. Include the four LAN subnets and 10.2.2.0/24. The example assumes this is the only tunnel in the WireGuard group. OPNsense alias reference.
Under Firewall → Rules, use direction In, version IPv4, Quick enabled, and source port Any. Keep scoped DHCP and local administration permits above the internal blocks, then place general internet permits below them. On each interface, apply these rules in the listed order. OPNsense firewall rules guide.
| Interface | Action | Source | Destination | Protocol and destination port |
|---|---|---|---|---|
| A WAN | Pass | B’s public WAN IPv4 | A’s WAN IPv4 | UDP 51820 |
| B WAN | Pass | A’s public WAN IPv4 | B’s WAN IPv4 | UDP 51820 |
| A trusted, B trusted, A IoT and B IoT | Pass | That interface’s subnet | Its local gateway IP | TCP/UDP 53 |
| A trusted only | Pass, with Gateway set to default | 10.10.10.0/24 | 10.20.10.20/32 | TCP 443 |
| A trusted, B trusted, A IoT and B IoT | Block, with Log enabled on IoT | That interface’s subnet | INTERNALS | Any |
| B WireGuard group | Pass | 10.10.10.0/24 | 10.20.10.20/32 | TCP 443 |
| B WireGuard group, below its pass | Block | Any | Any | Any |
| A WireGuard group | Block | Any | Any | Any |
The NAS must listen on TCP 443 and accept A’s trusted subnet in its host firewall, if enabled. Keep the pass rules stateful so HTTPS replies can return. Check floating and group rules for earlier broad passes that would override the LAN blocks. After changing policy, remove any affected states under Firewall → Diagnostics → States. OPNsense firewall rules and states.
Apply the firewall rules before activating WireGuard. On 26.7.10, open VPN → WireGuard → Instances on both sites. Select Enable WireGuard below the tabs and click Apply. The site-to-site guide lists this step under VPN → WireGuard → Settings. OPNsense site-to-site guide, 26.7.10 menu, 26.7.10 global settings form and 26.7.10 setup screen.
DNS and discovery
Point clients at their local gateway for DNS. On both firewalls, open Services → Unbound DNS → Overrides and add an A record with Host nas, Domain site-b.example, and IP 10.20.10.20. Check Access Lists if a local subnet cannot query Unbound. Use the NAS’s actual certificate name in place of the example if it differs. OPNsense Unbound reference and Mozilla’s certificate guide.
Bonjour uses link-local multicast DNS, so use the DNS name for cross-site access. IGMP snooping manages multicast forwarding on the local switch. Multicast DNS in RFC 6762 and IGMP snooping in RFC 4541.
CGNAT, dynamic WANs and MTU
If A has a changing WAN address or sits behind NAT, make A the initiator and use B as the reachable responder. Replace the two WAN rules above with the responder’s rule below. If B is the initiator, swap the WAN roles and keep the same tunnel IPs, Allowed IPs and NAS rules. OPNsense site-to-site guide.
| Setting | Initiator | Reachable responder |
|---|---|---|
| Peer endpoint address and port | Responder’s public IPv4 or DNS name, port 51820 | Leave address and port blank |
| Peer keepalive interval | 25 seconds to maintain an idle NAT or firewall mapping | Leave blank |
| WAN rule for this tunnel | Outbound initiation and stateful replies | Pass inbound IPv4 UDP 51820 to the responder’s WAN address. Use the initiator’s public IPv4 as source if fixed, or Any if it changes |
The responder learns the address and port from authenticated WireGuard traffic. If it sits behind an upstream router you control, manually forward UDP 51820 on that router to the responder’s OPNsense WAN address. Leave UPnP disabled. WireGuard manual, OPNsense port-forward reference and Ubiquiti’s UPnP guide.
A WAN address in 100.64.0.0/10 is in the shared range reserved for carrier-grade NAT. If neither site can receive inbound UDP, arrange a reachable public endpoint. If a configured endpoint hostname changes, use System → Settings → Cron to schedule Renew DNS for WireGuard on stale connections. RFC 6598 and OPNsense’s endpoint guidance.
For IPv4 TCP, set Max mss under Firewall → Settings → Normalization on the WireGuard group at both sites. Match any direction, protocol, source and destination. Subtract at least 40 bytes from the tunnel MTU, giving 1380 or lower at MTU 1420. OPNsense’s MSS clamping example.
Things to test before you call it done
| Check | What to do | Expected result |
|---|---|---|
| HTTPS from A trusted | Open https://nas.site-b.example/ in a browser, substituting your NAS hostname | The NAS login page loads with a certificate trusted by the client |
| Handshake on both firewalls | After the HTTPS attempt, open VPN → WireGuard → Status (called Diagnostics in the site-to-site guide) and find the peer | Handshake Age shows a recent handshake. Sent and Received increase during traffic |
| IoT isolation at both sites | From a device on each IoT VLAN, open the same NAS URL and then https://10.20.10.20/. In Firewall → Log Files → Live View, filter for the IoT client’s address and destination 10.20.10.20 | The login page stays unreachable, and each local firewall logs a block to TCP 443 |
| Local internet egress | In System → Routes → Status, check the default route on both firewalls | Each firewall’s default route still uses its local WAN |
A certificate warning during the IoT check means the browser reached a TLS service. Verify the firewall block in the log. Mozilla’s certificate guide, OPNsense WireGuard status reference, 26.7.10 Status screen, firewall logging guide and routing table guide.
For an optional throughput check, temporarily duplicate the NAS pass rules on A trusted and B’s WireGuard group with destination TCP 5201 above the blocks. Allow that port from A trusted in the NAS host firewall and run the server on the NAS if it has iperf3. OPNsense firewall rules and ESnet’s iperf3 manual.
iperf3 -s -B 10.20.10.20
Run these from A trusted to measure both directions.
iperf3 -c 10.20.10.20 -t 10
iperf3 -c 10.20.10.20 -t 10 -R
Stop iperf3 and remove the temporary permissions when finished. If the handshake or HTTPS checks fail, see OPNsense WireGuard troubleshooting.
Evidence and limits. The configuration is based on the OPNsense site-to-site and firewall documentation at revision bf5be04, with WireGuard controls checked against the 26.7.10 source. The example was not run in a lab.