Skip to content

WireGuard Peer Config Generator

Pure frontend: enter an endpoint, port, tunnel subnet and placeholder keys to get two config templates plus the supporting commands. No private key is generated on, or leaves, this page.

How to use

Enter the public endpoint (IP or DDNS name), UDP listen port, tunnel subnet and the server's tunnel address, then give the peer a tunnel address. Leave the key fields as placeholders — the generator writes markers and reminds you to replace them. Hit Generate config to get a server wg0.conf and a peer config, along with key generation, port opening and forwarding commands.

Configs come in pairs

WireGuard has no strict server and client role, only peers. By convention, the machine with a public address that stays online is called the server and the one dialling out is the peer. A working setup always has two halves: host A puts its own private key and its tunnel address in Interface, and B's public key in Peer; host B does the mirror image. Swap the public keys and the handshake never happens.

Tunnel addresses must be in the same subnet and must not collide. The generator defaults to the first address in the subnet for the server and the second for the peer, both written as /32. The /32 is deliberate: it pins one device to one tunnel address instead of letting a peer claim the whole range.

Every key in the output is a placeholder, and that is on purpose. A key generated in a browser travels through the page, the clipboard and downloaded files; for production keys the safer route is the official command on the machine that will use the key. Run umask 077, then wg genkey | tee private.key | wg pubkey > public.key. Put each machine's public key into the other's Peer section, keep private keys on their own host and out of chat threads and repositories.

AllowedIPs is the field worth understanding

The name is a little misleading — this is not only about who may connect. On a peer, it decides which destinations are sent through the tunnel: 0.0.0.0/0 sends everything, while a single LAN subnet sends only that traffic. On the server, it decides which source addresses that peer is allowed to use and helps the kernel attribute return packets to the right peer.

Site-to-site setups most often trip here. If the server's Peer section lists only 10.8.0.2/32, the two tunnel endpoints can reach each other but the 192.168.20.0/24 behind the peer cannot — that network is neither admitted nor routed. Put both the peer's tunnel address and its LAN subnet in AllowedIPs, mirrored on both ends. Subnets claimed by different peers must not overlap, or return-packet attribution becomes ambiguous.

Routing and forwarding come after the handshake

Seeing a recent handshake in wg show is not the finish line; the classic complaint is "I can ping the tunnel address but not the LAN behind it". That is usually a layer-three forwarding issue, not a crypto one.

First check routing: the system needs a route to the remote LAN via wg0. With wg-quick, networks in AllowedIPs are normally installed automatically, but if the handshake works and traffic does not flow, confirm with ip route get <remote-lan-address> rather than guessing. Second check the forwarding switch: a machine acting as a gateway needs net.ipv4.ip_forward enabled persistently under /etc/sysctl.d, not echoed once into /proc.

Third check NAT and firewall: whether return packets make it back depends on the remote LAN routing them to this host or on MASQUERADE here. The FORWARD chain also has to allow traffic between wg0 and the external interface. None of these are encryption concerns, yet all of them decide whether the tunnel is useful. The generator prints the relevant commands below the config; adapt interface names before running.

UDP and keepalive

WireGuard uses UDP only. Port 51820 is the conventional listen port, not a protocol-mandated default: wg picks a random port when ListenPort is unset, which is why the generator writes the port into the config explicitly. Whichever port you choose, open it on the server firewall and cloud security group. If the endpoint is a DDNS name, remember that peers cache resolved addresses — after a name changes, check what each side actually resolved before suspecting encryption.

PersistentKeepalive belongs only on the side behind NAT. NAT mappings expire when idle, and a small periodic packet keeps the mapping alive so the peer can initiate traffic. A publicly reachable endpoint normally does not need it; 25 seconds is a common starting value, not something to increase blindly.

Official documentation