NebulaVPN · Guides

The WireGuard config file explained, line by line

Updated: 5 min read

When you download a WireGuard or AmneziaWG config, you get a small text file or a QR code. Most people import it and never look inside. But knowing what each line does helps you fix problems, set up split tunneling, and understand why you should guard that file like a password. This guide walks through a typical config line by line.

A typical config

Here is what a WireGuard config looks like. The keys and addresses are examples, not real ones.

[Interface]
PrivateKey = yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk=
Address = 10.8.0.2/32
DNS = 1.1.1.1
MTU = 1420

[Peer]
PublicKey = xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg=
PresharedKey = /UwcSPg38hW/D9Y3tcS1FOV0K1wuURMbS0sesJEP5ak=
Endpoint = 203.0.113.10:51820
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25

The file has two sections. [Interface] describes your side of the tunnel. [Peer] describes the server you connect to.

The [Interface] section

PrivateKey

Your device's secret key. WireGuard identifies every device by a key pair: a private key that never leaves the device, and a matching public key that the server knows. Anyone who has your private key can connect as you, use your plan, and appear to the server as your device.

This is the single most important line in the file. Treat the whole config, and its QR code, like a password: do not post screenshots of it, do not show it in screen recordings, and do not send it in group chats. If it leaks, ask your provider to issue a new config; the old key is then removed from the server and stops working.

Address

The private IP address your device gets inside the tunnel, such as 10.8.0.2/32. It is not your public IP and is not visible on the internet. The server uses it to know which tunnel to send replies to. The /32 means "exactly this one address". A config may also include an IPv6 address on the same line, separated by a comma.

DNS

The DNS server your device uses while the tunnel is up. DNS translates names like example.com into IP addresses. Setting it in the config makes sure those lookups travel through the tunnel instead of going to your local network's DNS server. If this line is missing, you may have a DNS leak; see how to test for leaks.

MTU

The largest packet size the tunnel will send. WireGuard's default is 1420 bytes, which leaves room for its own headers inside a normal 1500-byte packet. On some mobile networks, or on networks that add their own layers, 1420 is still too big and large transfers stall. Lowering it to 1380 or 1280 often fixes "some sites load, others hang". This line is optional; if it is missing, the app picks a value automatically.

ListenPort (usually absent on clients)

Servers need a fixed port that clients connect to. Clients normally do not, so this line is usually left out of client configs and the app picks a random port.

The [Peer] section

PublicKey

The server's public key. Your device uses it to make sure it is really talking to your provider's server and not an impostor. It is safe to share; it is public by design.

PresharedKey

An optional extra secret shared by your device and the server. WireGuard's normal key exchange is already strong; the preshared key adds a second layer, mainly as protection against future attacks by quantum computers on today's recorded traffic. Like the private key, it should stay secret.

Endpoint

The server's public address and port, such as 203.0.113.10:51820. It can also be a domain name. This is where your device sends its encrypted packets. If the server's address or port is blocked by your network, the tunnel will never complete a handshake.

AllowedIPs

This line is the most misunderstood. On the client, it means "which destination addresses should be sent into the tunnel". It works like a routing table:

Including ::/0 matters even if the server has no IPv6, because it prevents IPv6 traffic from leaking outside the tunnel. For more on splitting traffic, read split tunneling explained.

PersistentKeepalive

How often, in seconds, your device sends a tiny packet to the server when nothing else is being sent. Many home routers and mobile networks forget a UDP connection after 30 seconds or so of silence; the keepalive stops that from happening, so the server can reach you at any time. 25 seconds is the usual value. It costs under 10 KB per hour of data.

Extra lines in AmneziaWG configs

AmneziaWG configs have the same lines plus a few in the [Interface] section that change how packets look from the outside:

Jc = 4
Jmin = 40
Jmax = 70
S1 = 52
S2 = 71
H1 = 1394827561
H2 = 2048311739
H3 = 873221904
H4 = 1652089773

These values must match the server exactly, so do not change them. They are why an AmneziaWG config does not work in the plain WireGuard app. Our protocol comparison explains why this disguise matters on filtered networks.

What you can safely change

LineSafe to edit?Why you might
MTUYesFix stalls on some networks
DNSYesUse a faster or preferred resolver
AllowedIPsYes, carefullySplit tunneling
PersistentKeepaliveYesFix drops after idle time
PrivateKey, PublicKey, PresharedKeyNoMust match the server
AddressNoAssigned by the server
EndpointOnly if your provider tells youServer address
Jc, Jmin, Jmax, S1, S2, H1 to H4NoMust match the server

Where your config lives on each device

Wherever it lives, back it up somewhere private. And if you ever share your screen while the config or its QR code is visible, ask your provider for a new one.

More guides