WireGuard Fast VPN tunnels
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
wg genkey | tee privatekey | wg pubkey > publickey
sudo wg-quick up <iface>
sudo wg-quick down <iface>
sudo wg showsudo systemctl enable --now wg-quick@<iface>
wg genpsksudo wg set <iface> peer <pubkey> remove
sudo wg syncconf <iface> <(wg-quick strip
<iface>)
Concepts
- Packet to 10.0.0.2
- Peer matching key
- Endpoint ip:port
Keys
wg genkey > privatekey
wg pubkey < privatekey > publickey
wg genpsk > psk
wg genkey | tee privatekey | wg pubkey
Bring up and down
sudo wg-quick up <iface>
sudo wg-quick down <iface>
sudo wg-quick up <path>.conf
sudo wg-quick save <iface>
wg-quick strip <iface>
sudo systemctl enable --now wg-quick@<iface>
sudo systemctl restart wg-quick@<iface>
sudo ip link set <iface> up
Inspect
sudo wgsudo wg show <iface>
sudo wg show <iface> latest-handshakes
sudo wg show <iface> transfer
sudo wg show <iface> allowed-ips
sudo wg show <iface> endpoints
sudo wg show interfaces
sudo wg show <iface> dump
sudo wg showconf <iface>
Change live
sudo wg set <iface> peer <pubkey> allowed-ips
<cidr> endpoint <ip:port>
sudo wg set <iface> peer <pubkey> remove
sudo wg set <iface> peer <pubkey> allowed-ips
+<cidr>
sudo wg set <iface> peer <pubkey>
persistent-keepalive 25
sudo wg set <iface> peer <pubkey> preshared-key
<file>
sudo wg set <iface> listen-port <port>
sudo wg set <iface> private-key <file>
sudo wg setconf <iface> <file>
sudo wg addconf <iface> <file>
sudo wg syncconf <iface> <file>
Config file
| Field | Meaning |
|---|---|
PrivateKey |
Own secret key |
Address |
Tunnel IP, e.g. 10.0.0.1/24 |
ListenPort |
UDP port (51820 usual) |
DNS |
Resolver for the tunnel |
MTU |
Override detected MTU |
Table |
off stops route creation |
PostUp / PostDown |
Shell hooks; %i is iface |
SaveConfig |
Rewrite file on down |
| Field | Meaning |
|---|---|
PublicKey |
Peer's public key |
AllowedIPs |
IPs sent to peer |
Endpoint |
host:port to dial |
PersistentKeepalive |
Secs; 25 if NAT |
PresharedKey |
Optional extra secret |
[Interface]PrivateKey = <private key>Address = 10.0.0.2/24[Peer]PublicKey = <peer public key>Endpoint = vpn.example.com:51820AllowedIPs = 10.0.0.0/24PersistentKeepalive = 25
Routing
| Value | Effect |
|---|---|
10.0.0.2/32 |
Only that one host |
10.0.0.0/24 |
A whole subnet |
0.0.0.0/0, ::/0 |
All traffic via peer |
ip route get <ip>
sudo sysctl -w net.ipv4.ip_forward=1
PostUp = iptables -t nat -A POSTROUTING -o <eth> -j
MASQUERADE
Troubleshoot
sudo wg showsudo ss -ulpn | grep <port>
ping <peer tunnel ip>
sudo journalctl -u wg-quick@<iface>
echo module wireguard +p | sudo tee
/sys/kernel/debug/dynamic_debug/control
Recipes
# server: wg0.conf[Interface]Address = 10.0.0.1/24ListenPort = 51820PrivateKey = <server private>[Peer]PublicKey = <client public>AllowedIPs = 10.0.0.2/32
sudo wg set wg0 peer <pubkey> allowed-ips 10.0.0.3/32# persist itsudo wg-quick save wg0
sudo wg syncconf wg0 <(wg-quick strip wg0)
[Peer]PublicKey = <server public>Endpoint = vpn.example.com:51820AllowedIPs = 0.0.0.0/0, ::/0



