WireGuard can be used on OpenWrt routers to connect two LANs in different locations. After configuration, devices on both sides can access each other as if they were connected through a private routed network.
This is useful for home labs, NAS access, remote monitoring, backup synchronization and small office interconnection.
Basic Topology
Assume there are two sites:
|
|
Each OpenWrt router runs WireGuard. One side can act as the peer with a public endpoint, or both sides can connect through a reachable server.
Install WireGuard
On OpenWrt, install the required packages:
|
|
After installation, the LuCI web interface can configure WireGuard interfaces.
Create Keys
Generate private and public keys for each side:
|
|
Keep private keys secret. Exchange only public keys between the two routers.
Configure The Tunnel
Create a WireGuard interface on each router, for example wg0.
Example tunnel addresses:
|
|
For Site A, add Site B as a peer and set allowed IPs to:
|
|
For Site B, add Site A as a peer and set allowed IPs to:
|
|
These routes tell each router which remote subnet should go through the WireGuard tunnel.
Firewall And Routing
Create or assign a firewall zone for the WireGuard interface. Allow forwarding between LAN and WireGuard zones according to your policy.
At minimum, each side needs:
- LAN to WireGuard forwarding;
- WireGuard to LAN forwarding;
- UDP port open for WireGuard on the side with a public endpoint;
- correct allowed IPs for the remote subnet.
If NAT is not required, routed access is cleaner. Each LAN should know that the other LAN is reachable through the WireGuard router.
Test Connectivity
After both sides are configured, test the tunnel address first:
|
|
Then test a host in the remote LAN:
|
|
If tunnel IPs work but LAN hosts fail, check firewall forwarding and remote subnet routes.
Summary
OpenWrt plus WireGuard is a lightweight way to connect two remote LANs. The important points are key exchange, tunnel addresses, allowed IPs, firewall forwarding and correct routing between the two LAN segments.