C.W.K.
Stream
Lesson 03 of 12 · published

WireGuard Concepts

~12 min · wireguard, concepts, peer, allowedips

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

Conceptually simple

WireGuard has just a few moving parts. Once these click, the configs make obvious sense.

  • Interface — a virtual network adapter (e.g. wg0). Each device gets one, with its own private key and an IP on the VPN subnet.
  • Peer — another device this one wants to talk to, identified by its public key.
  • Endpoint — the real IP:port of a peer (only needed for peers that should be "always reachable," like a server).
  • AllowedIPs — what destination IPs should be routed through the tunnel to a particular peer. 0.0.0.0/0 = everything; 10.0.0.2/32 = just that one IP.

The SSH analogy

WireGuard auth works almost exactly like SSH authorized_keys:

SSHWireGuard
Generate a key pairGenerate a key pair
Install public key in authorized_keysAdd public key in a [Peer] block
Private key never leaves your machineSame
Connect by hostnameConnect by endpoint (only for the "server" peer)

If you understood SSH keys (Track 2), you already understand WireGuard's trust model.

Code

What an INI config looks like·ini
# /etc/wireguard/wg0.conf — client side
[Interface]
PrivateKey = <client-private-key>
Address = 10.0.0.2/24
DNS = 1.1.1.1

[Peer]
PublicKey = <server-public-key>
Endpoint = your-server.example.com:51820
AllowedIPs = 0.0.0.0/0          # route ALL traffic through tunnel
PersistentKeepalive = 25         # keep NAT mappings alive (only on clients)

External links

Exercise

Read the INI config above. Identify: which key the [Interface] section needs (private), which key the [Peer] section needs (public), what AllowedIPs would mean if you changed it from 0.0.0.0/0 to 10.0.0.0/24 (only tunnel traffic to that subnet, everything else uses your normal route).

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.