WG(8)
๐ WG(8) ๐
okay bestie, gather round, because this is the manual page for wg(8) โ the WireGuard config utility โ and it's genuinely iconic.
โจ NAME โจ
wg โ set and retrieve configuration of WireGuard interfaces ๐
๐ธ SYNOPSIS ๐ธ
wg [ COMMAND ] [ OPTIONS ]... [ ARGS ]...
๐ฆ DESCRIPTION ๐ฆ
so like. wg is the configuration utility for getting and setting the configuration of WireGuard tunnel interfaces. that's the whole vibe. ๐ซถ
the interfaces themselves โ the actual tunnel devices โ get added and removed using ip-link(8), and their IP addresses and routing tables get set using ip-address(8) and ip-route(8). wg doesn't do that part, that's not her job. what wg does is give you a series of sub-commands for changing the WireGuard-specific aspects of WireGuard interfaces. she's a specialist. she's booked and busy. ๐
if no COMMAND is specified, COMMAND defaults to show. no cap. you just type wg and she shows you things.
โ ๏ธ sub-commands that take an INTERFACE must be passed a WireGuard interface. like, an actual WireGuard one. she will not be fooled. ๐ญ
๐ COMMANDS ๐
๐ show
show { <interface> | all | interfaces } [public-key | private-key |
listen-port | fwmark | peers | preshared-keys | endpoints | allowed-ips
| latest-handshakes | persistent-keepalive | transfer | dump]
shows the current WireGuard configuration and runtime information of the specified <interface> โจ
- if no
<interface>is specified,<interface>defaults toall. everyone's invited to the group chat. - if
interfacesis specified, it prints a list of all WireGuard interfaces, one per line, and quits. just the names. a little roll call. ๐ - if no options are given after the interface specification, then it prints a list of all attributes in a visually pleasing way meant for the terminal. for you. because you deserve nice things.
- otherwise, it prints specified information grouped by newlines and tabs, meant to be used in scripts. script-friendly, no decoration, all business.
- for this script-friendly display, if
allis specified, then the first field for all categories of information is the interface name. so you always know who's who. ๐ - if
dumpis specified, then several lines are printed. the first contains, in order separated by tab:private-key,public-key,listen-port,fwmark. subsequent lines are printed for each peer and contain, in order separated by tab:public-key,preshared-key,endpoint,allowed-ips,latest-handshake,transfer-rx,transfer-tx,persistent-keepalive. literally the full tea, tab-separated. ๐ฅ
๐ธ showconf <interface>
shows the current configuration of <interface> in the format described by CONFIGURATION FILE FORMAT below. it's giving copy-paste-able. ๐
๐ set
set <interface> [listen-port <port>] [fwmark <fwmark>] [private-key
<file-path>] [peer <base64-public-key> [remove] [preshared-key <file-
path>] [endpoint <ip>:<port>] [persistent-keepalive <interval seconds>]
[allowed-ips [+|-]<ip1>/<cidr1>[,[+|-]<ip2>/<cidr2>]...] ]...
sets configuration values for the specified <interface>. okay so here's the tea, option by option: ๐ซ
- multiple peers may be specified, and if the
removeargument is given for a peer, that peer is removed, not configured. bye bestie ๐ - if
listen-portis not specified, or set to0, the port will be chosen randomly when the interface comes up. surprise port! ๐ - both
private-keyandpreshared-keymust be files, because command line arguments are not considered private on most systems. ngl that's just facts. but if you are usingbash(1), you may safely pass in a string by specifying asprivate-keyorpreshared-keythe expression:<(echo PRIVATEKEYSTRING)โ process substitution, we love her ๐ - if
/dev/nullor another empty file is specified as the filename for eitherprivate-keyorpreshared-key, the key is removed from the device. - the use of
preshared-keyis optional, and may be omitted; it adds an additional layer of symmetric-key cryptography to be mixed into the already existing public-key cryptography, for post-quantum resistance. extra armour, extra slay. ๐ฅ - if
allowed-ipsis specified, but the value is the empty string, all allowed ips are removed from the peer. clean slate, fresh start. ๐ง - by default,
allowed-ipsreplaces a peer's allowed ips. if+or-is prepended to any of the ips then the update is incremental; ips prefixed with'+'or''are added to the peer's allowed ips if not present, while ips prefixed with'-'are removed if present. patch notes energy. ๐ - the use of
persistent-keepaliveis optional and is by default off; setting it to0or"off"disables it. otherwise it represents, in seconds, between1and65535inclusive, how often to send an authenticated empty packet to the peer, for the purpose of keeping a stateful firewall or NAT mapping valid persistently. for example, if the interface very rarely sends traffic, but it might at anytime receive traffic from a peer, and it is behind NAT, the interface might benefit from having a persistent keepalive interval of25seconds; however, most users will not need this. (most users will not need this. she said it once. she'll say it again.) ๐ - the use of
fwmarkis optional and is by default off; setting it to0or"off"disables it. otherwise it is a 32-bit fwmark for outgoing packets and may be specified in hexadecimal by prepending"0x". hex girlies rise ๐
๐ setconf <interface> <configuration-filename>
sets the current configuration of <interface> to the contents of <configuration-filename>, which must be in the format described by CONFIGURATION FILE FORMAT below. full replace, no mercy, periodt. ๐
๐ addconf <interface> <configuration-filename>
appends the contents of <configuration-filename>, which must be in the format described by CONFIGURATION FILE FORMAT below, to the current configuration of <interface>. additive. gentle. she's just adding to the collection. ๐ซถ
๐ฆ syncconf <interface> <configuration-filename>
like setconf, but reads back the existing configuration first and only makes changes that are explicitly different between the configuration file and the interface. this is much less efficient than setconf, but has the benefit of not disrupting current peer sessions. the contents of <configuration-filename> must be in the format described by CONFIGURATION FILE FORMAT below. slow and steady keeps the call connected. ๐
๐ genkey
generates a random private key in base64 and prints it to standard output. boom. secret acquired. ๐คซ
๐ genpsk
generates a random preshared key in base64 and prints it to standard output. more secrets. more slay.
โจ pubkey
calculates a public key and prints it in base64 to standard output from a corresponding private key (generated with genkey) given in base64 on standard input. it's a glow-up pipeline: private in, public out. ๐
a private key and a corresponding public key may be generated at once by calling:
$ umask 077
$ wg genkey | tee private.key | wg pubkey > public.key
๐ help
shows usage message. when in doubt, ask for help. iconic behaviour. ๐ซถ
๐ง CONFIGURATION FILE FORMAT ๐ง
the configuration file format is based on INI. there are two top level sections โ Interface and Peer. multiple Peer sections may be specified, but only one Interface section may be specified. one interface, many peers. main character energy. ๐
the Interface section may contain the following fields:
PrivateKeyโ a base64 private key generated bywg genkey. Required.ListenPortโ a 16-bit port for listening. Optional; if not specified, chosen randomly.FwMarkโ a 32-bit fwmark for outgoing packets. If set to0or"off", this option is disabled. May be specified in hexadecimal by prepending"0x". Optional.
the Peer sections may contain the following fields:
PublicKeyโ a base64 public key calculated bywg pubkeyfrom a private key, and usually transmitted out of band to the author of the configuration file. Required.PresharedKeyโ a base64 preshared key generated bywg genpsk. Optional, and may be omitted. This option adds an additional layer of symmetric-key cryptography to be mixed into the already existing public-key cryptography, for post-quantum resistance.AllowedIPsโ a comma-separated list of IP (v4 or v6) addresses with CIDR masks from which incoming traffic for this peer is allowed and to which outgoing traffic for this peer is directed. The catch-all0.0.0.0/0may be specified for matching all IPv4 addresses, and::/0may be specified for matching all IPv6 addresses. May be specified multiple times.Endpointโ an endpoint IP or hostname, followed by a colon, and then a port number. This endpoint will be updated automatically to the most recent source IP address and port of correctly authenticated packets from the peer. Optional.PersistentKeepaliveโ a seconds interval, between1and65535inclusive, of how often to send an authenticated empty packet to the peer for the purpose of keeping a stateful firewall or NAT mapping valid persistently. For example, if the interface very rarely sends traffic, but it might at anytime receive traffic from a peer, and it is behind NAT, the interface might benefit from having a persistent keepalive interval of25seconds. If set to0or"off", this option is disabled. By default or when unspecified, this option is off. Most users will not need this. Optional.
๐ CONFIGURATION FILE FORMAT EXAMPLE ๐
this example may be used as a model for writing configuration files, following an INI-like syntax. characters after and including a # are considered comments and are thus ignored. so go ahead, annotate your heart out. โ๏ธ
[Interface]
PrivateKey = yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk=
ListenPort = 51820
[Peer]
PublicKey = xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg=
Endpoint = 192.95.5.67:1234
AllowedIPs = 10.192.122.3/32, 10.192.124.1/24
[Peer]
PublicKey = TrMvSoP4jYQlY6RIzBgbssQqY3vxI2Pi+y71lOWWXX0=
Endpoint = [2607:5300:60:6b0::c05f:543]:2468
AllowedIPs = 10.192.122.4/32, 192.168.0.0/16
[Peer]
PublicKey = gN65BkIKy1eCE9pP1wdc8ROUtkHLF2PfAqYdyYBz6EA=
Endpoint = test.wireguard.com:18981
AllowedIPs = 10.10.10.230/32
๐ฅ DEBUGGING INFORMATION ๐ฅ
sometimes it is useful to have information on the current runtime state of a tunnel. she's mysterious. let's make her talk. ๐ต๏ธโโ๏ธ
when using the Linux kernel module on a kernel that supports dynamic debugging, debugging information can be written into dmesg(1) by running as root:
# modprobe wireguard && echo module wireguard +p > /sys/kernel/debug/dynamic_debug/control
on OpenBSD and FreeBSD, debugging information can be written into dmesg(1) on a per-interface basis by using ifconfig(1):
# ifconfig wg0 debug
on userspace implementations, it is customary to set the LOG_LEVEL environment variable to verbose. ๐
๐ ENVIRONMENT VARIABLES ๐
okay so these are the little environment gremlins that change how wg acts, and they are literally so important. no cap. ๐
WG_COLOR_MODEโ bestie, this controls the ANSI colorized output. If you set it toalways, then it will always print ANSI colorized output. If you set it tonever, then it will never print ANSI colorized output. If you set it toauto, or to something invalid, or if it's just unset, then it will print ANSI colorized output only when writing to a TTY. periodt. โจWG_HIDE_KEYSโ okay so if you set this tonever, then the pretty-printingshowsub-command will show private and preshared keys in the output. ๐ If you set it toalways, or to something invalid, or if it's unset, then private and preshared keys will be printed as"(hidden)". so if you're screen-sharing, maybe don't set it tonever, iykyk. ๐WG_ENDPOINT_RESOLUTION_RETRIESโ if you set this to an integer or toinfinity, then DNS resolution for each peer's endpoint will be retried that many times for non-permanent errors, with an increasing delay between retries. ๐ If it's unset, the default is15retries. so yes, it will keep trying, and the delay gets bigger each time. no cap. ๐ซ
๐ SEE ALSO ๐
๐ AUTHOR ๐
wg was written by Jason A. Donenfeld. For updates and more information, a project page is available on the World Wide Web. ๐ like, go look, bestie, it's giving iconic.
this page is serving major main character energy, brought to you by ZX2C4 and dated 2015 August 13, for the WG(8) manual. mwah ๐
๐ฆ where this page comes from
- alpine 3.22: wireguard-tools-doc 1.0.20250521-r0 ยท GPL-2.0-only
- alpine 3.23: wireguard-tools-doc 1.0.20250521-r1 ยท GPL-2.0-only
- alpine 3.24: wireguard-tools-doc 1.0.20260223-r0 ยท GPL-2.0-only
- arch rolling: wireguard-tools 1.0.20260223-1 ยท GPL
- centos-stream 10: wireguard-tools 1.0.20250521-1.el10 ยท GPL-2.0-only
- fedora 43: wireguard-tools 1.0.20250521-2.fc43 ยท GPL-2.0-only
- fedora 43: wireguard-tools 1.0.20260223-1.fc43 ยท GPL-2.0-only
- fedora 44: wireguard-tools 1.0.20250521-3.fc44 ยท GPL-2.0-only
- fedora 44: wireguard-tools 1.0.20260223-1.fc44 ยท GPL-2.0-only
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: wireguard-tools 1.0.20260223
- ubuntu resolute: wireguard-tools 1.0.20250521-1ubuntu1 ยท GPL-2.0-only
- ubuntu stonking: wireguard-tools 1.0.20260223-1ubuntu2 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms