27 WireGuard site to site
Two sites joined by an encrypted WireGuard tunnel across a shared network, routing each other's LANs.
What you practice
- A WireGuard tunnel with
wg-quick: keys,AllowedIPsand endpoints - Routing whole LANs through a tunnel
- Seeing that only encrypted UDP crosses the shared network
Topology
| Node | Image | CPUs / memory | Addresses | Role |
|---|---|---|---|---|
gwa | debian-13 | 1 / 1GiB | mgmt 10.127.0.11; lan 192.168.1.1/24 | Site A gateway, wg0 10.99.0.1 |
gwb | debian-13 | 1 / 1GiB | mgmt 10.127.0.12; lan 192.168.2.1/24 | Site B gateway, wg0 10.99.0.2 |
ha | debian-13 | 1 / 1GiB | mgmt 10.127.0.13; lan 192.168.1.10/24 | Host at site A |
hb | debian-13 | 1 / 1GiB | mgmt 10.127.0.14; lan 192.168.2.10/24 | Host at site B |
Before you start
bash
vz image pull disk debian-13Run it
bash
cd examples/27-wireguard-site-to-site
vz validate
vz up
vz node ls
ssh lab@10.127.0.11 # password: labFirst boot installs packages; give it a minute or two after vz up returns.
Try it
bash
ssh lab@10.127.0.11 'sudo wg show'
ssh lab@10.127.0.13 'traceroute -n 192.168.2.10' # ha -> gwa -> (tunnel) -> gwb -> hb
ssh lab@10.127.0.11 'sudo tcpdump -ni mgmt -c 6 udp port 51820' &
ssh lab@10.127.0.13 'ping -c 3 192.168.2.10' # tcpdump shows only UDP 51820
vz port down gwb/mgmt # the tunnel's path is gone
vz port up gwb/mgmt # traffic resumes within secondsNotes
The keys in init/gwa and init/gwb were generated for this example and are public now. Use them only in this lab: wg genkey | tee private | wg pubkey > public makes new ones. The mgmt switch stands in for the internet between the two sites.
Clean up
bash
vz down
vz destroy --yes # deletes the overlays and state of this lab