Most guides answer "how do I add a WireGuard peer?" with wg-quick down wg0 && wg-quick up wg0. That works, and it also disconnects everyone currently using the tunnel in order to add one line to a file. On a server with a handful of clients it is a brief annoyance. On a server you actually rely on, it is the reason people avoid adding peers at all.
There is a command that does it live.
How do you add a peer to WireGuard?
One line, on the running interface:
wg set wg0 peer <CLIENT_PUBLIC_KEY> allowed-ips 10.0.0.5/32
The peer exists from that moment. No restart, no dropped handshakes, no interruption for anyone already connected. wg set talks to the kernel module directly and edits the live configuration of the interface.
Confirm it took:
wg show wg0
The new public key appears in the list, with no handshake yet, that is expected, the handshake happens when the client first sends traffic.
How do you add a peer from the command line, start to finish?
On the client machine, generate the key pair:
wg genkey | tee client.key | wg pubkey > client.pub
client.key is the private key and never leaves that machine. client.pub is what the server needs.
On the server:
wg set wg0 peer "$(cat client.pub)" allowed-ips 10.0.0.5/32
Back on the client, the config file needs the server's public key, its endpoint, and the address you just assigned:
[Interface]
PrivateKey = <contents of client.key>
Address = 10.0.0.5/32
[Peer]
PublicKey = <SERVER_PUBLIC_KEY>
Endpoint = vpn.example.com:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25
The two keys are the step people get wrong: each side holds the other side's public key, never its own.
If the new client is a phone, or a machine without wg installed, you can produce its side without a terminal. Set our free WireGuard config generator to one client and your server's endpoint and subnet: it creates the key pair in your browser and gives you the client file, its QR code and the matching [Peer] block for the server. Two things to check before use. The generator invents its own server key pair, so replace PublicKey in the client's [Peer] block with your real one from wg show wg0 public-key. And it assigns the first client the .2 address of the subnet, so change Address (and the allowed-ips you pass to wg set) if that one is already taken. The client's private key and the public key you hand to the server are ready as they are. The generator is free with no account, up to 250 devices, and its ZIP export holds every client .conf and its QR code as a PNG, handy to set up a whole office or family in one go.
Generate your WireGuard configs here
Type your server address, choose the number of devices, then scan each QR code from the app.
All keys are generated in your browser (Curve25519 / X25519). Nothing is sent to our servers - your config stays 100% private.
Public IPv4 or domain of the machine that will run WireGuard. No server yet? Leave it empty and add it later.
Free, no account: up to 250 clients, each .conf with its QR code, and one ZIP with every file.
Everything the device sends to the internet goes through your server.
Advanced settingsTunnel subnet, DNS, site-to-site LANs. The defaults work for most setups.
Optional. Enter the LAN subnet behind the server and/or behind a client that acts as a site gateway (a router, a Raspberry Pi, a NAS). The generator adds each LAN to the server's AllowedIPs, gives every peer the routes to the other LANs, and writes the forwarding rules on the gateways. Leave a field empty for a normal client.
What you download
wg0.conf
for the server
client1.conf
one per device
QR (sample)
for the phone app
Illustration only: the lines and the QR code are fictional, no real key. Your real files are generated in your browser when you click.
What goes in AllowedIPs when you add a peer?
It depends which side you are on, and this asymmetry is the source of most confusion.
| On the server, for this peer | On the client, for the server | |
|---|---|---|
| What it means | which address belongs to this client | which traffic to send through the tunnel |
| Typical value | 10.0.0.5/32, one address | 0.0.0.0/0 (everything) or the LAN subnet (split tunnel) |
| Can it overlap another peer? | No | not applicable |
| Effect if wrong | packets go to the wrong peer, or are dropped | traffic bypasses the tunnel, or the tunnel captures your LAN |
The no-overlap rule is structural rather than tidiness. AllowedIPs is what tells WireGuard which peer a given destination belongs to, so an address listed on two peers makes that decision ambiguous, and the practical symptom is that adding a client silently knocks the previous one offline.
On the client side, the full tunnel 0.0.0.0/0 is easy; "everything except my LAN" is not, because AllowedIPs has no exclusion syntax. Our free AllowedIPs calculator turns "everything except X" into the shortest list of IPv4 and IPv6 ranges to paste into the new client's [Peer] block.
How do you make the new peer survive a reboot?
wg set changes the running interface. It does not touch /etc/wireguard/wg0.conf, so a reboot forgets it. Two ways to persist:
Add the block to the file by hand:
[Peer]
PublicKey = <CLIENT_PUBLIC_KEY>
AllowedIPs = 10.0.0.5/32
Do not write the live state back with wg showconf wg0 > /etc/wireguard/wg0.conf, a shortcut that circulates widely. wg showconf only knows what the kernel knows: the private key, the listen port and the peers. It has none of the wg-quick lines, Address, DNS, MTU, PostUp, PostDown. Overwrite the file with it and the next wg-quick up brings wg0 up with no tunnel address and no NAT rules, so every client handshakes and nothing routes.
If you want the running state saved for you, set SaveConfig = true in [Interface]. wg-quick then writes the peers back when the interface goes down and keeps its own lines. The catch: it rewrites the whole file at that moment, so a comment or a hand edit made while the tunnel is up is lost. Pick one method, hand-edited file or SaveConfig, not both.
To reload an edited file without dropping sessions:
wg syncconf wg0 <(wg-quick strip wg0)
syncconf applies the differences. wg-quick down/up does not, it rebuilds the interface from scratch, which is exactly what you were trying to avoid.
How do you script adding peers on Linux?
The sequence has no interactive step, so it scripts directly:
#!/usr/bin/env bash
set -euo pipefail
NAME="$1"; IP="$2" # ./addpeer.sh laptop 10.0.0.7
umask 077
wg genkey | tee "$NAME.key" | wg pubkey > "$NAME.pub"
wg set wg0 peer "$(cat "$NAME.pub")" allowed-ips "$IP/32"
printf '\n[Peer]\n# %s\nPublicKey = %s\nAllowedIPs = %s/32\n' \
"$NAME" "$(cat "$NAME.pub")" "$IP" >> /etc/wireguard/wg0.conf
echo "added $NAME at $IP"
umask 077 matters: without it the freshly written private key is readable by every account on the box. set -euo pipefail matters too, without it, a failed wg set still leaves you with key files and a cheerful success message. The printf line appends the peer to the file instead of rewriting it, for the reason given in the previous section.
A fuller version of this script is free on GitHub: wg-newpeer.sh also generates a preshared key, writes the client .conf to ./clients/, applies the change with wg syncconf and prints a QR code when qrencode is installed. It ships in our paid WireGuard Self-Hosting Kit (9 USD) next to the server and client templates, the 12-cause troubleshooting checklist and the hardening checklist, if you want the whole set as files.

A hand resting on the keyboard while the monitor stays black, adding a peer with wg set produces no visible confirmation at all, which is why wg show is the only thing that tells you it worked.
Why doesn't the new peer connect?
The command succeeded and nothing happens. In practice it is almost always one of four things, and all four are checkable rather than guessable.
- The keys are swapped. The server holds the client's public key; the client holds the server's. Putting a private key where a public one belongs fails silently.
- The client is behind NAT with no
PersistentKeepalive. The server has no route back until the client speaks first, and the NAT mapping expires in between.PersistentKeepalive = 25on the client side keeps it open. - The address is already taken. Two peers with the same
AllowedIPsis the case that looks the most mysterious, because the older peer is the one that breaks. - The server's UDP port is not reachable from outside. Existing peers on the LAN still work, so the server looks fine, but a new peer on mobile data never gets a handshake. Our free WireGuard port checker tells you whether your router can forward the port at all (it detects CGNAT and double NAT) and gives the firewall rule for your system. If the answer is CGNAT, no port forwarding will fix it: the usual way out is to run the server on a VPS with its own public IPv4, such as a Contabo Cloud VPS (affiliate link), and add your peers there. If you would rather have a US host with a 30-day money-back guarantee, Ultahost VPS Basic is 5.52 $ a month on a 24-month term (1 GB RAM, dedicated IPv4, read on 21 October 2026), enough for a WireGuard server for a few devices.
That third failure is what wg-clients-audit exists for. It reads a folder of client configs and reports duplicate addresses, reused private keys, and AllowedIPs ranges broad enough to swallow the local network, the three faults that produce a tunnel which connects and then behaves strangely. Running it before you hand a config to someone is faster than diagnosing it afterwards.
Start with wg show wg0. A peer with no latest handshake never completed one, which points at keys or reachability. A peer that handshakes but carries no data points at AllowedIPs.
While you are editing a peer block, it is the right moment to consider a preshared key: one wg genpsk per peer pair, mixed into the handshake, and it must match on both ends or the tunnel goes quiet.
A VPN changes your IP. It does not change your browser.
A tunnel replaces the address a service sees. It changes nothing about what your browser announces on its own - fonts, screen, time zone, graphics stack - and that combination is often stable enough to recognise you across sessions, tunnel or no tunnel.
Measure your own browser fingerprint - passive, no questions, no account, no email.
What to remember
wg set adds a peer live; wg-quick down/up disconnects everyone to do the same job. Whatever you add live is gone on reboot unless you also write it to the config, and wg showconf is not a config file: redirect it over wg0.conf and you lose Address and PostUp. One /32 per client, never overlapping. And when a new peer misbehaves, check wg show before changing anything, the difference between "no handshake" and "handshake but no traffic" tells you which half of the setup to look at.
And if you were about to copy one config onto a second device instead of adding a peer, the symptom that follows is documented: two devices, one WireGuard key.
Affiliate link
★ Nuremberg GDPR datacenter · ✓ Dedicated IPv4 included · 200 Mbit/s port
Self-host your VPN on your own VPS → ContaboCloud VPS 4 · 5,50 €/mo · Card or PayPal · orders from outside the EU accepted→Price checked 17 Oct 2026, 24-month term


