OPNsense Router
Flat isometric illustration of a dark cube topped by a pink keyhole shield, a curved cable linking it to a second server cube on a pink-edged pad.
Troubleshooting

OPNsense WireGuard Setup Problems: Handshake, NAT, MTU

Fix an OPNsense WireGuard tunnel that won't connect: read the handshake, then check the WAN rule, keys, allowed addresses, outbound NAT, DNS and MTU.

By OPNsense Router Editorial · ·Updated · 11 min read

If OPNsense WireGuard is not connecting, read the peer’s latest handshake under VPN, WireGuard, Status first. If no handshake appears, check the WAN path to the UDP listen port, the WAN pass rule, and the peer and keys. If the handshake is recent but traffic fails, check tunnel rules, Allowed IPs, Source NAT and DNS as applicable. If small packets pass but large transfers stall, check MTU and MSS.

Steps were checked against OPNsense documentation, the 24.1 and 26.7 release notes, and FreeBSD wg(4) on 26 November 2026. No hands-on testing was performed for this guide.

The WireGuard quick start explains that WireGuard tries to stay quiet while idle.

Read the handshake before changing anything

Under VPN, WireGuard, Status, the VPN reference lists the instances and peers with their last known handshake and data exchanged. The site-to-site guide uses the label Diagnostics.

No handshake, ever. Check whether the client can reach the WAN listen port, whether the WAN rule passes that UDP traffic, and whether the intended peer is selected with the correct keys.

A handshake is recent, but tunnel traffic fails. Check the tunnel-side firewall rule and Allowed IPs. If local destinations work but internet destinations fail, check Source NAT and the rule’s destination. If IP addresses work but names fail, check DNS.

A handshake exists and small traffic works, but large transfers stall. Check the tunnel MTU and the MSS clamping rule.

No handshake: causes to check

The WAN rule is missing

The road warrior guide requires a WAN pass rule: action Pass, direction in, protocol UDP, source any, destination WAN address, destination port range set to the instance’s listen port. It suggests 51820 or a higher numbered unique port.

The road warrior setup configures the tunnel under VPN and puts the inbound pass rule on WAN. See how OPNsense firewall rules, NAT and interfaces actually work.

The peer is not attached to the instance

After creating the peer, return to VPN, WireGuard, Instances and open the instance. Select the new peer in the Peers dropdown, then click Save, followed by Apply.

The keys are crossed

The client’s public key goes into the peer entry on OPNsense. The instance’s public key goes into the client’s configuration under [Peer]. In this setup, each device keeps its own private key.

The instance’s key fields start blank until you press the cogwheel to generate keys. Save the instance, click Save again, then reopen it and copy its public key.

This IPv4-only full-tunnel client example is based on the guide’s appendix. Replace every placeholder with your own values. The appendix warns against reusing its example keys.

[Interface]
# Client's own private key; its public key goes into the OPNsense peer
PrivateKey = <client-private-key>
# Must match the peer's Allowed IPs on OPNsense, for example 10.10.10.2/32
Address = 10.10.10.2/32
DNS = <resolver-address>

[Peer]
# The OPNsense instance's public key
PublicKey = <instance-public-key>
# Route all IPv4 destinations through the tunnel
AllowedIPs = 0.0.0.0/0
Endpoint = <your-public-hostname-or-ip>:51820
# Optional for a peer behind NAT that needs to receive packets while idle
# PersistentKeepalive = 25

Public endpoint reachability

Check that the client’s Endpoint uses the OPNsense host’s public IP address or publicly resolvable hostname and the instance’s UDP listen port. If you accept inbound WireGuard traffic through an upstream NAT router you control, forward the UDP listen port to OPNsense.

In the OPNsense site-to-site guide, endpoint hostnames are resolved when the tunnel starts. If both sites use dynamic DNS names as endpoints and either gets a new WAN IP lease, see the site-to-site routing setup for the stale-connection DNS renewal job.

The tunnel address is a single host address

The guide states that the instance tunnel address must not be a /32 for IPv4 or a /128 for IPv6. Use a tunnel address in CIDR form with a subnet large enough for all client tunnel addresses, for example 10.10.10.1/24.

Still no handshake? Follow the packet

Capture UDP on the listen port on WAN during a connection attempt. An empty capture recorded no matching packets on the selected interface. An inbound packet shows it reached that interface. If only inbound packets appear, the capture shows no reply on that interface. An outbound reply shows that the capture recorded the reply on that interface. In its discussion of policy-based routing, the firewall manual notes that return traffic can use a different interface.

  1. Rule log. On the current rules page, the firewall manual says to enable the rule’s Log option and use the live log viewer to see whether it matches. On legacy rules, it names Firewall, Log Files, Live View. If the log shows a block on the listen port, check which rule matched and review the rule order.
  2. Packet capture. In Packet Capture under Interfaces, Diagnostics, select WAN, protocol UDP and the listen port, then bring the tunnel up. The diagnostics page lets you view the capture, even while it runs, or download the pcap files. The WireGuard protocol documentation explains why unauthorized clients receive no response.
  3. Debug messages. The VPN reference says to check VPN, WireGuard, Log File first for setup errors. Runtime debugging is available from the console with ifconfig. Find the instance’s device under VPN, WireGuard, Status. The FreeBSD wg(4) manual gives ifconfig wgN debug for runtime debugging. Substitute the actual device name, such as wg0, for wgN.

With debugging on, wg(4) documents four messages:

MessageMeaningFix
Handshake for peer X did not complete after 5 seconds, retryingThis side’s initiation got no answerCheck, for example, whether the remote side lists this interface as a peer, whether the endpoint IP is correct, and whether firewall rules allow communication
Invalid handshake initiationThe receiver could not process the initiation. A likely cause is an incorrect sender public key in the local peer configuration.Verify the sender’s public key in the local peer entry
Invalid initiation MACThe initiation MAC was invalid. The sender likely used the wrong public key for the receiver.Verify the receiver’s public key in the sender’s peer entry
Packet has unallowed src IP from peer XA decrypted packet’s source is outside that peer’s Allowed IPsFor a road warrior peer, check that the Allowed IPs field includes the client’s tunnel address

Handshake works, but tunnel traffic fails

There is no rule on the tunnel side

The road warrior WAN rule allows clients to connect to the WireGuard instance. The guide adds a second pass rule on the interface assigned to the WireGuard device, from the tunnel subnet alias to whatever the client should access.

For an unassigned device, put the pass rule on the automatically created WireGuard group and set Source to the tunnel subnet, for example 10.10.10.0/24. Assigning the device creates a tunnel subnet alias and lets you set rules per instance. When automatic NAT rules are enabled, assignment also creates an IPv4 Source NAT rule.

Allowed IPs on OPNsense and the client

In the road warrior setup, the OPNsense peer’s Allowed IPs field lists each client tunnel address as a /32 or /128 within a subnet configured on the instance, such as 10.10.10.2/32. Packets arriving from that peer with a source outside its Allowed IPs are dropped.

On the client, AllowedIPs lists the destinations routed into the tunnel. For a full tunnel, use 0.0.0.0/0 for IPv4 and ::/0 for IPv6 when the tunnel is configured for that family. The example above uses IPv4 only. To route only local destinations through the tunnel, list those local subnets.

If the client routes all IPv4 traffic through the tunnel and the tunnel-side pass rule allows one destination subnet, traffic to that subnet can match the rule. Destinations outside that subnet need a matching pass rule.

The VPN reference says inbound traffic outside a peer’s Allowed IPs is silently dropped and does not appear in a packet capture. Check for the unallowed src IP debug message to confirm a source-address mismatch.

Local network works, internet does not

If the client can reach internal hosts, check whether the tunnel-side pass rule also allows the intended internet destinations. Then check Source NAT for the tunnel address family. The road warrior guide uses WAN interface address translation for IPv4 internet access and for IPv6 tunnels using unique local addresses (ULAs). The guide says IPv6 global unicast addresses (GUAs) do not need NAT.

When automatic NAT rules are enabled, assigning the WireGuard device as an interface adds the IPv4 Source NAT rule. For manual IPv4 translation with an unassigned tunnel, open Firewall, NAT, Source NAT (Outbound). If Hybrid Source NAT rule generation is not already selected, select it, click Save, then Apply changes. Add a rule with Interface set to WAN, TCP/IP Version set to IPv4, Source address set to the tunnel subnet, and Translation / target set to Interface address. Click Save, then Apply changes. The NAT manual says hybrid keeps the automatic rules alongside yours, while manual mode generates no automatic rules.

Names do not resolve

The instance has a DNS Server field. The guide says to leave it blank, otherwise WireGuard will overwrite OPNsense’s DNS configuration. For the client file above, use its DNS field.

Separately, the guide notes that if Unbound DNS is configured with all interfaces registered, assigning the interface requires a reload of Unbound DNS to get the new WireGuard interface added.

Handshake works, small traffic works, large transfers stall

Check MTU and MSS. The road warrior guide notes that ICMP and UDP can work even when some encrypted TCP sessions fail.

The default instance MTU is 1420. The guide uses 1412 with PPPoE and specifies an MTU 80 bytes below the WAN MTU.

Under Firewall, Settings, Normalization, create one MSS clamping rule. Set Interface to WireGuard (Group) and Direction to Any. Set Protocol, Source, Destination and Destination port to any. Choose Max mss for the traffic that passes through the tunnel, then save the rule.

  • IPv4 only. Use a value 40 bytes below the tunnel MTU. The guide gives 1380 by default or 1372 with PPPoE.
  • IPv6 only or dual-stack. Use a value 60 bytes below the tunnel MTU. The guide gives 1360 by default or 1352 with PPPoE.

Ping a host across the tunnel from Interfaces, Diagnostics with Do not fragment set. The diagnostics documentation names that option for locating MTU problems.

Keepalive for an idle peer behind NAT or a firewall

The quick start says WireGuard tries to be as silent as possible when not being used. A peer behind NAT or a firewall that needs to receive packets while idle must keep the mapping valid. The quick start suggests a keepalive interval of 25 seconds. It also says: “If you don’t need this feature, don’t enable it.” The site-to-site guide uses the same 25 seconds on the side behind NAT.

The 24.1 release notes record that the kernel WireGuard plugin moved to core on January 30, 2024 and that os-wireguard-go was discontinued. The site-to-site guide still lists an os-wireguard plugin installation step. The issue behind that move proposed renaming Local to Instances and Endpoints to Peers, the names the current guide uses.

The 26.7 series, released July 15, 2026 on FreeBSD 15.1, includes these changes:

  • Firewall rules now default to the API-driven page, and the legacy rules pages moved to the os-firewall-legacy plugin. The firewall manual calls the new page Firewall, Rules, and the old one Firewall, Rules [legacy]. The legacy plugin is not installed by default. To check WAN rules on the new page, select WAN in the interface filter.
  • The NAT manual lists the page as Firewall, NAT, Source NAT (Outbound), and 26.7.5 (September 30, 2026) moved the old outbound NAT page to the legacy plugin.
  • 26.7.3 (August 27, 2026) lists a WireGuard change for FreeBSD 15 no longer allowing addresses without netmasks, so write tunnel addresses in CIDR form.

The notes for 26.7.6, 26.7.7 (October 13, 2026), 26.7.8 (October 30, 2026) and 26.7.9 (November 11, 2026) list no WireGuard changes.

When to restart WireGuard

The road warrior guide calls for a restart if WireGuard was already running when you attached the peer. It also calls for a restart after interface assignment or adding a manual Source NAT rule. Under VPN, WireGuard, General, turn WireGuard off, click Apply, turn it back on, and click Apply again.

A short checklist

  1. Read the peer’s latest handshake time.
  2. Confirm a WAN pass rule for UDP on the listen port exists.
  3. Select the peer in the instance and confirm you clicked Save, then Apply.
  4. Confirm the client’s public key is in the peer, and the instance’s public key is in the client.
  5. Confirm the instance tunnel address uses CIDR notation and its subnet includes the client tunnel addresses.
  6. If there is still no handshake, capture UDP on WAN on the listen port and run ifconfig wgN debug, substituting the instance’s device name for wgN.
  7. Confirm a pass rule covers the intended destinations on the assigned WireGuard interface or on the WireGuard group with the tunnel subnet as its source.
  8. In this setup, check the OPNsense peer’s Allowed IPs for the client’s tunnel address and the client’s AllowedIPs for the routed destinations.
  9. Check Source NAT for tunneled internet access using IPv4 or IPv6 ULAs.
  10. Leave the instance DNS field blank, and reload Unbound after assigning the interface if it has all interfaces registered.
  11. If large transfers stall, check tunnel MTU and the MSS clamping rule for the traffic’s address families.

See OPNsense hardware requirements, the state table and bandwidth sizer and WireGuard vs OpenVPN vs IPsec on OPNsense.

FAQ

why is opnsense wireguard connected but no internet

Check the tunnel-side rule’s destination and the Source NAT requirements for the tunnel address family. See Local network works, internet does not for the IPv4 rule and IPv6 cases.

what port does wireguard use on opnsense

WireGuard on OPNsense uses the instance’s UDP listen port. The road warrior guide suggests 51820 or a higher numbered unique port. Set the WAN pass rule’s destination port to that number. If you accept inbound traffic through an upstream NAT router you control, forward that UDP port to OPNsense.

what does handshake did not complete after 5 seconds mean

The peer did not reply to that handshake initiation within five seconds, so this side is retrying. The wg(4) table above lists examples of what to check.

why did wireguard stop working after an opnsense update

Check VPN, WireGuard, Log File for setup errors. Existing legacy firewall rules continue to work after the 26.7 rules page move, even without the legacy plugin. See Menu names that do not match older guides.

Sources

  1. WireGuard Road Warrior Setup - OPNsense documentation
  2. Firewall - OPNsense documentation
  3. Network Address Translation - OPNsense documentation
  4. WireGuard: Protocol & Cryptography
  5. WireGuard: Quick Start (PersistentKeepalive)
  6. Virtual Private Networking - OPNsense documentation
  7. WireGuard Site-to-Site Setup - OPNsense documentation
  8. Interfaces Diagnostics - OPNsense documentation
  9. wg(4) - FreeBSD Manual Pages
  10. OPNsense 24.1 Savvy Shark series release notes
  11. OPNsense 26.7 Xenial Xenops series release notes
  12. interfaces: move WireGuard kernel plugin to core - opnsense/core issue 6827

Related