English
简体中文繁體中文EnglishРусскийفارسی

Home › Guides › Add and remove devices

Add and remove devices

Adding and removing WireGuard devices, pausing one, reloading without dropping others, limiting where a device may go, and replacing lost keys.

Adding or removing a device takes one line each
Adding or removing a device takes one line each The original uploader was J.smith at English Wikipedia., CC BY-SA 2.5

Add one

Server
wg genkey | tee tv.key | wg pubkey > tv.pub
sudo nano /etc/wireguard/wg0.conf      # add a [Peer] at the end
sudo wg syncconf wg0 <(wg-quick strip wg0)

One address per device. Keep a list, and use # for notes in the config.

AddressDeviceAdded
10.8.0.2Laptop2026-11-02
10.8.0.3Phone2026-11-02
10.8.0.4TV2026-12-01

Remove one

At once, others stay connected
sudo wg set wg0 peer THEIR_PUBLIC_KEY remove

This changes memory only. Delete the block from the file too or it returns after a restart.

Let it reach one place only

On the server AllowedIPs says whose source address it is, not what it may visit. Use the firewall for that:

10.8.0.4 may reach the NAS only
sudo iptables -I FORWARD -s 10.8.0.4 -j DROP
sudo iptables -I FORWARD -s 10.8.0.4 -d 192.168.1.10 -j ACCEPT

Lost phone

  1. Remove its peerThe remove command above
  2. Edit the fileDelete its [Peer] block
  3. New keysA fresh pair for the new phone, not the old one
Done in five minutes
Should I add a PresharedKey?

You can. It adds a symmetric layer per pair; wg genpsk makes it, and both sides write the same.

How many devices can a server take?

The protocol has no limit; bandwidth and CPU decide. Dozens are fine on a small VPS.

Next letterKeep it running

On the same round

Postcodes: WireGuard add peer, WireGuard remove peer, WireGuard multiple clients