Lesson 8 of 9 · 26m
WireGuard on the Router: Small, Fast Remote Access Done Correctly
Build a router-hosted WireGuard service with sane keys, routing, firewall policy, DNS behavior, and operational verification.
Opening SSH or LuCI to the Internet is how a useful router becomes someone else's router. WireGuard gives you a better boundary: a small authenticated tunnel, modern cryptography, simple key identity, and a configuration that fits in your head. It is still remote access, though. If peers can route into everything, you have merely moved the blast radius behind cleaner crypto.
Install and model the tunnel
opkg update
opkg install wireguard-tools luci-proto-wireguard
wg genkey | tee /root/wg-router.key | wg pubkeyA minimal logical interface uses a transit network that does not overlap common home or office subnets:
config interface 'wg0'
option proto 'wireguard'
option private_key 'ROUTER_PRIVATE_KEY'
option listen_port '51820'
list addresses '10.77.0.1/24'Overlap creates routes that work in demos and fail in real hotels.
Peers are cryptographic identities
Each client gets a unique keypair and tunnel address. On the router, a peer stanza stores the client public key and typically allows only that peer's tunnel address, such as 10.77.0.2/32.
The client configuration chooses what reaches the tunnel:
[Interface]
PrivateKey = CLIENT_PRIVATE_KEY
Address = 10.77.0.2/32
[Peer]
PublicKey = ROUTER_PUBLIC_KEY
AllowedIPs = 10.77.0.0/24, 192.168.10.0/24
Endpoint = vpn.example.net:51820AllowedIPs is both routing policy and cryptokey routing. Traffic absent from it does not magically find another path.
Firewall policy decides what VPN means
Put the interface in its own vpn zone and forward only to approved destination zones.
If the WireGuard router is not the LAN default gateway, either add return routes on the real gateway or NAT VPN traffic. NAT is easier and uglier; routing is cleaner and requires cooperation.
Expose only the tunnel endpoint
If this router is the perimeter device, WAN needs a narrow UDP 51820 accept rule.
That exposes WireGuard, not LuCI or SSH. Verify with evidence:
wg show
tcpdump -ni wg0 icmp
tcpdump -ni br-lan icmp and host 192.168.10.50A handshake without application traffic usually means routes or firewall policy. No handshake points toward endpoint reachability, NAT forwarding, ISP filtering, time, or keys.
Field notes
- Remove peers when devices are retired; key lifecycle is access-control lifecycle.
- QR configuration is convenient, but screenshots can leak private keys into cloud photo libraries.
persistent_keepalivehelps NAT traversal; it is not a substitute for correct firewalling.- Full-tunnel
AllowedIPs = 0.0.0.0/0changes the client's default route. Choose split tunnel deliberately. - Time synchronization matters; badly wrong clocks complicate rotation and TLS diagnostics.
Was this lesson helpful?