WireGuard site to site and mesh config generator

List the nodes, say which of them have a public address and what networks are behind them, and take a ready wg0.conf for each one: two sites, a star with a hub, or a full mesh. Keys and preshared keys are made in your browser, AllowedIPs and keepalives are worked out, overlapping networks are named before they break anything.

Runs in your browser, nothing is sent

Settings

Site to site: two networks joined by one tunnel.

Node 1
Node 2
Result

The result will show up here.

Everything is worked out in your browser: keys and addresses are not sent anywhere.

Server ready? Connect to it in Veli: paste the link or the file into Add. The app can also set up a VPN on your VPS by itself.

Download Veli

Reference

Two sites, a star or a mesh

The shape decides how many [Peer] sections each file has, who needs a public address, and what it is good for.

Two sites
Peers in a file: one
Public address: at one of the two at least
Good for: an office and a home, two offices, a cloud network and an office
Star
Peers in a file: one at a node, all the nodes at the hub
Public address: at the hub only
Good for: many nodes behind NAT, laptops and phones
Mesh
Peers in a file: all the other nodes it can reach
Public address: at one of each pair; a pair behind NAT goes through a third node
Good for: servers that exchange a lot of data

What the lines of a node's file do

Address
The node's address in the tunnel, with the prefix of the tunnel network.
ListenPort
The port others dial. Only nodes with a public address have it.
AllowedIPs
Which addresses are behind this peer: traffic to them goes to it, and packets from it are accepted only with them. wg-quick adds routes by this line.
Endpoint
Where to dial. A peer behind NAT has none: it dials itself.
PersistentKeepalive
25 seconds at nodes behind NAT: it keeps the way through the router open, so others can reach the node.
PresharedKey
A key of its own for each pair on top of the main ones, the same in both files.
PreUp, PostUp, PostDown
Turn on forwarding, let traffic through the firewall and, if chosen, do NAT into the node's network. %i is the interface name.

FAQ

How do I connect two sites with WireGuard?

One node at each site, and at least one of them needs a public address. Each file has one [Peer] with the other node's tunnel address and the network behind it in AllowedIPs. The devices of each site then need a way to the tunnel: the node is their router, or the router has a static route to it, or the node does NAT.

Star or mesh: what is the difference?

In a star all nodes connect to one hub and talk to each other through it: files are short, and one public address is enough, but all traffic goes through the hub. In a mesh every pair is connected directly: faster, but each file lists all the others and a new node means editing every file.

What if two nodes are both behind NAT?

Plain WireGuard can't connect them: neither has an address the other could dial. Their traffic goes through a third node with a public address, which forwards it. Pick that node in the mesh, and their networks are added to its AllowedIPs.

Why must the networks be different?

WireGuard picks the peer by AllowedIPs, and one network can belong to one peer only. If both sites use 192.168.1.0/24, a packet to 192.168.1.5 has nowhere to go: renumber one of them, for example to 192.168.20.0/24.

The tunnel is up, but devices behind the nodes don't see each other. Why?

Usually the way back is missing: a device answers through its own router, which knows nothing about the tunnel. Add a static route on that router (the “What to do” tab lists them) or turn NAT on at the node. Also check that forwarding is on: the files do it with PreUp.

Can I open such a file in Veli?

A file with one [Peer] that has an Endpoint, yes: a laptop in a star, for example. Veli takes one [Peer] and doesn't run PostUp, so a gateway for a whole network should run wg-quick or a router. For MikroTik and OpenWrt, pass the file to “WireGuard for a router”.