Site-to-site WireGuard VPN connection with OpenWRT

I recently connected two sites, each behind its own OpenWrt router, with a WireGuard tunnel. The goal sounds simple: servers on both sides should reach each other by their LAN IPs, but only inter-site traffic should use the VPN. Everything else (internet, apt, container pulls) should keep leaving through each site's own WAN.

Getting there took a few wrong turns: a site that lost internet the moment the tunnel came up, a handshake that worked while no traffic flowed, and a server whose own WireGuard client silently hijacked its traffic. This post is the clean, working setup, done entirely in the LuCI web interface, followed by the troubleshooting notes I wish I'd had.

The design

  • Site A (192.168.13.0/24) runs the WireGuard server and listens on UDP 51820.
  • Site B (192.168.14.0/24) is the client. It initiates the connection and keeps it alive.
  • The tunnel subnet is 10.13.0.0/24: A is 10.13.0.1, B is 10.13.0.2.
  • Traffic is routed, not NATed, so servers see each other's real IP addresses.
  • Servers need no VPN software and no static routes. The routers do all of the split routing.
SITE A LAN 192.168.13.0/24 OpenWrt A (server) LAN 192.168.13.1 wg0 10.13.0.1/24 :51820 Servers 192.168.13.x gw 192.168.13.1 SITE B LAN 192.168.14.0/24 OpenWrt B (client) LAN 192.168.14.1 wg0 10.13.0.2/24 Servers 192.168.14.x gw 192.168.14.1 WireGuard tunnel (UDP 51820) only 192.168.13/14.0/24 + 10.13.0.0/24 WAN → internet WAN → internet

Addressing plan

ItemSite ASite B
RoleWireGuard serverWireGuard client
LAN subnet192.168.13.0/24192.168.14.0/24
Router LAN IP (server gateway)192.168.13.1192.168.14.1
wg0 tunnel address10.13.0.1/2410.13.0.2/24
Listen port51820/udp—
Peer endpoint— (B connects in)Site A public IP or DDNS name, port 51820
Peer Allowed IPs10.13.0.2/32, 192.168.14.0/2410.13.0.0/24, 192.168.13.0/24
The one rule that matters most: never put 0.0.0.0/0 in a peer's Allowed IPs in this design. With "Route Allowed IPs" enabled, it turns the tunnel into that router's default route, and the site loses internet access the moment the VPN comes up. Also keep the two LANs, the tunnel subnet and each router's WAN-side network from overlapping.

Prerequisites (both routers)

  1. OpenWrt 22.03 or newer (fw4/nftables). I used 23.05; 24.10 works the same.
  2. In System → Software, click Update lists, then install luci-proto-wireguard. This also pulls in wireguard-tools and the kernel module. Optionally install tcpdump for troubleshooting.
  3. Reboot, so the WireGuard VPN protocol shows up in LuCI.
  4. In System → System → Time Synchronization, make sure the NTP client is enabled. WireGuard rejects handshakes with a timestamp older than the last one it accepted.
  5. Site A must be reachable on UDP 51820 from the internet. If A's WAN IP is private (it sits behind an ISP modem), forward the port on that modem. If the WAN IP falls in 100.64.0.0/10, A is behind CGNAT: get a public IP from the ISP, or swap the server and client roles.

Site A: WireGuard server

1. Create the wg0 interface

  1. Go to Network → Interfaces → Add new interface…, set the name to wg0 and the protocol to WireGuard VPN.
  2. On the General Settings tab:
    • Private Key: click Generate new key pair and copy the resulting Public Key. Site B needs it.
    • Listen Port: 51820
    • IP Addresses: 10.13.0.1/24
  3. On the Firewall Settings tab, assign the zone vpn (created below).

2. Add site B as a peer

On the Peers tab, click Add peer:

FieldValue
Descriptionsite-B
Public KeySite B's public key
Preshared KeyEmpty, or identical on both sides
Allowed IPs10.13.0.2/32
192.168.14.0/24
Route Allowed IPs✔ checked
Endpoint / KeepaliveLeave empty (B connects in and sends keepalives)
Why 192.168.14.0/24 is mandatory: WireGuard's Allowed IPs is both a routing table and a source-address filter. Without this entry, A silently drops every packet from B's LAN, even though the handshake succeeds.

3. Open the port on A's WAN

Go to Network → Firewall → Traffic Rules → Add: name Allow-WireGuard, protocol UDP, source zone wan, destination zone Device (input), port 51820, action accept.

The equivalent UCI config, for reference:

# /etc/config/network  (Site A)
config interface 'wg0'
	option proto 'wireguard'
	option private_key '<SITE_A_PRIVATE_KEY>'
	option listen_port '51820'
	list addresses '10.13.0.1/24'

config wireguard_wg0
	option description 'site-B'
	option public_key '<SITE_B_PUBLIC_KEY>'
	list allowed_ips '10.13.0.2/32'
	list allowed_ips '192.168.14.0/24'
	option route_allowed_ips '1'

# /etc/config/firewall  (Site A only)
config rule
	option name 'Allow-WireGuard'
	option src 'wan'
	option proto 'udp'
	option dest_port '51820'
	option target 'ACCEPT'

Site B: WireGuard client

1. Create the wg0 interface

  1. Go to Network → Interfaces → Add new interface… and create wg0 with protocol WireGuard VPN.
  2. On the General Settings tab: generate a key pair and copy B's Public Key into A's peer. Leave Listen Port empty, and set IP Addresses to 10.13.0.2/24.
  3. On the Advanced Settings tab, leave Use custom DNS servers empty.
  4. On the Firewall Settings tab, assign the zone vpn.
Lesson learned: my site B wg0 still had a leftover 192.168.0.2/24 address from an earlier attempt. The handshake worked fine, but A dropped everything the router sent, because that source IP wasn't in A's Allowed IPs. Double-check the tunnel addresses on both sides.

2. Add site A as a peer

FieldValue
Descriptionsite-A
Public KeySite A's public key
Allowed IPs10.13.0.0/24
192.168.13.0/24
not 0.0.0.0/0
Route Allowed IPs✔ checked
Endpoint Host / PortSite A's public IP or DDNS name / 51820
Persistent Keep Alive25
# /etc/config/network  (Site B)
config interface 'wg0'
	option proto 'wireguard'
	option private_key '<SITE_B_PRIVATE_KEY>'
	list addresses '10.13.0.2/24'

config wireguard_wg0
	option description 'site-A'
	option public_key '<SITE_A_PUBLIC_KEY>'
	option endpoint_host '<SITE_A_PUBLIC_IP_OR_DDNS>'
	option endpoint_port '51820'
	option persistent_keepalive '25'
	list allowed_ips '10.13.0.0/24'
	list allowed_ips '192.168.13.0/24'
	option route_allowed_ips '1'

Key cross-check

Routerwg0 → Private KeyPeer → Public Key
Site AA privateB public
Site BB privateA public

Status → WireGuard shows each router's own public key at the top. Compare it character by character with what the other router has in its peer.

Firewall zone (both routers)

Go to Network → Firewall → Zones → Add:

FieldValue
Namevpn
Input / Output / Forwardaccept / accept / accept
Masqueradingoff (routed, servers see real IPs)
MSS clampingon (prevents stalls on HTTPS/SMB)
Covered networkswg0
Forward to / fromlan / lan

Afterwards, the zone overview must still show lan ⇒ wan next to the new lan ⇒ vpn and vpn ⇒ lan. The wan zone must keep Masquerading on, and wg0 must not be in the wan zone. Click Save & Apply, then restart wg0 in Network → Interfaces: on A first, then on B.

# /etc/config/firewall  (both sites)
config zone
	option name 'vpn'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'ACCEPT'
	option masq '0'
	option mtu_fix '1'
	list network 'wg0'

config forwarding
	option src 'lan'
	option dest 'vpn'

config forwarding
	option src 'vpn'
	option dest 'lan'

The servers: keep them dumb

This is where the split tunnel pays off. Servers just use their local OpenWrt router as their only default gateway, and the router decides where each packet goes:

Destination (from a site B server)Server sends toRouter B sends via
192.168.13.0/24, 10.13.0.0/24192.168.14.1wg0 (VPN)
Everything else192.168.14.1WAN

DHCP from the router is the easiest option. For a static IP with netplan:

network:
  version: 2
  ethernets:
    ens160:
      dhcp4: false
      addresses: [192.168.14.208/24]
      routes:
        - to: default
          via: 192.168.14.1          # site A servers: 192.168.13.1
      nameservers:
        addresses: [192.168.14.1]    # site A servers: 192.168.13.1

Apply it with sudo netplan try, which rolls back automatically if you lose access. Remove old gateway4: lines and any manual routes to the other site.

Allow the remote site in the host firewall

# ufw (on a site B server; on site A use 192.168.14.0/24)
sudo ufw allow from 192.168.13.0/24
sudo ufw allow from 10.13.0.0/24

# firewalld
sudo firewall-cmd --permanent --zone=trusted --add-source=192.168.13.0/24
sudo firewall-cmd --permanent --zone=trusted --add-source=10.13.0.0/24
sudo firewall-cmd --reload

Watch out for VPN clients on the servers themselves

This one cost me the most time. ip route on a site B server looked perfect: default via 192.168.14.1. But it had no internet. The cause was a leftover wg-quick client on the server with AllowedIPs = 0.0.0.0/0. wg-quick puts its default route in a separate routing table (51820), selected via ip rule, so the main table looks innocent while all traffic disappears into another tunnel. Its DNS = line had also replaced the server's resolver, which broke apt.

ip rule                    # only rules 0, 32766, 32767 expected
ip route get 8.8.8.8       # must show: via 192.168.14.1
sudo wg show               # any unexpected local WireGuard?

# not needed:
sudo systemctl disable --now wg-quick@wg0
# needed, but only for its own network: in /etc/wireguard/wg0.conf set
#   AllowedIPs = 10.8.0.0/24   (instead of 0.0.0.0/0) and remove the DNS = line

On Docker and Kubernetes hosts, also make sure the container, pod and service CIDRs don't overlap 192.168.13.0/24, 192.168.14.0/24 or 10.13.0.0/24.

Verifying it works

WhereCheckExpected
Both: Status → WireGuardLatest handshakeUnder 2 minutes ago, RX/TX increasing
B: Status → RoutingRoutes0.0.0.0/0 → wan; 192.168.13.0/24 and 10.13.0.0/24 → wg0
A: Status → RoutingReturn route192.168.14.0/24 → wg0
B: Network → DiagnosticsPing 8.8.8.8, 10.13.0.1, 192.168.13.1All succeed
Site B serverip route get 8.8.8.8via 192.168.14.1
Site B serverping 192.168.13.2, sudo apt updateBoth work
Site A serverping 192.168.14.208, sudo apt updateBoth work

To prove the internet does not go through the VPN, run traceroute -n 1.1.1.1 on a site B server. Hop 1 is 192.168.14.1, hop 2 is B's upstream gateway, and 10.13.0.1 never appears.

Troubleshooting

No handshake at all

  • A isn't reachable: compare A's WAN IP (Status → Overview) with its real public IP. A private WAN IP means you need a port forward on the upstream modem. An address in 100.64.x.x means CGNAT.
  • Wrong endpoint: check that the DDNS name resolves to A's current IP, and that the ports match.
  • Keys crossed incorrectly, or a preshared key set on only one side.
  • Firewall: the A rule must target Device (input). Watch its counter in Status → Firewall while B tries to connect.
  • Clock: if B rebooted with the wrong time, fix NTP and restart wg0 on A.
  • Decisive test on A: tcpdump -ni any udp port 51820. If nothing arrives, the problem is in the network path. If packets arrive but get no reply, it's the keys.

Handshake OK, but no traffic

  • The remote LAN is missing from a peer's Allowed IPs, especially 192.168.14.0/24 on A.
  • A tunnel address doesn't match the plan.
  • Route Allowed IPs isn't checked.
  • wg0 has no firewall zone, or sits in wan.

Remote router answers, its servers don't

  • Pinging 192.168.13.1 only tests the router's input. Reaching servers needs vpn ⇒ lan forwarding.
  • The server's default gateway isn't the OpenWrt router, so replies go elsewhere.
  • The server's host firewall drops foreign subnets. Windows blocks ICMP from other subnets by default.
  • Run sudo tcpdump -ni any icmp on the target: no request arriving means a router problem; a request without a reply means a host problem.

Site B lost internet

  • 0.0.0.0/0 is in a peer's Allowed IPs. Check Status → Routing for a default route on wg0.
  • The lan ⇒ wan forwarding was removed while editing zones.
  • DNS points at a site A address. Check DHCP and DNS → Forwards and the interfaces' custom DNS fields.
  • A local VPN client on the server is capturing its traffic (see above).

Adding a third site

For site C (192.168.15.0/24, tunnel IP 10.13.0.3):

  • On A, add a peer with Allowed IPs 10.13.0.3/32 and 192.168.15.0/24.
  • On C, set Allowed IPs to 10.13.0.0/24 and 192.168.13.0/24, plus 192.168.14.0/24 if C should reach B through A.
  • On B, add 192.168.15.0/24 to the existing site A peer.
  • A's vpn zone already forwards vpn → vpn with Forward = accept, so A acts as the hub.
TL;DR: put only the remote subnets in Allowed IPs, never 0.0.0.0/0. On the server side, add the client's LAN to its peer. Give wg0 its own firewall zone without masquerading, and leave the servers alone: their only gateway is the local router.