Basics

The wg0.conf File Explained ([Interface] & [Peer])

3 min read

A WireGuard config has one [Interface] (this node) and one [Peer] block per other node. Here’s every field you’ll actually use.

Annotated example (a server)

[Interface]
# This node's own settings
Address = 10.0.0.1/24          # this node's VPN IP (and subnet)
ListenPort = 51820             # UDP port to listen on (servers only)
PrivateKey = THIS_NODE_PRIVATE_KEY

[Peer]
# One block per other node you connect to
PublicKey = OTHER_NODE_PUBLIC_KEY
AllowedIPs = 10.0.0.2/32       # which IPs this peer may use / route to it
# Endpoint = 203.0.113.5:51820 # the other node's address (clients set this for the server)
# PersistentKeepalive = 25     # set on the side behind NAT

[Interface] fields

[Peer] fields


Rule: a private key only ever appears in its own node’s [Interface]; a public key only ever appears in the other node’s [Peer]. Save the file as /etc/wireguard/wg0.conf (the wg0 becomes the interface name).

Open the full version (with copy buttons) ↗

← All recipes