Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Wireguard Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-wireguard-knowledge-patch)
---
name: wireguard-knowledge-patch
description: WireGuard
version: "1.0.20260223"
license: MIT
metadata:
author: Nevaberry
---
# WireGuard knowledge patch
Load this skill when configuring WireGuard peers, applying configuration changes,
using `wg-quick`, inspecting `wg` output, or ordering dependent systemd units.
It also covers platform requirements, DNS handling, logging, and the embeddable
C library's endpoint type.
| Reference | Topics |
| --- | --- |
| [CLI and peer state](references/cli-and-peer-state.md) | AllowedIPs updates, key and keepalive removal, endpoint retries, output, logging, Windows requirements, helpers, C endpoint storage |
| [systemd integration](references/systemd-integration.md) | Enabled service instances, target membership, dependent-unit startup ordering |
| [`wg-quick` configuration and Linux networking](references/wg-quick-configuration.md) | Configuration lookup, interface names, hooks, DNS, MTU, sysctl writes, DHCP and the example kill switch |
## Compatibility and changed behavior
### Windows command requirements
The `wg` command on `master` after `v1.0.20260223` requires Windows 10 or later.
`wg` no longer performs its own elevation on Windows: run commands that need
administrator privileges from an elevated shell.
Disabled WireGuard adapters are omitted from Windows interface listings.
Enable the adapter before looking for it with `wg show interfaces`.
### Removing peer settings with `wg syncconf`
If the peer remains in the configuration, deleting its `PresharedKey` entry and
running `wg syncconf` clears the live key in place.
Starting with `v1.0.20260223`, removing `PersistentKeepalive` from the peer's
configuration and reapplying it with `wg syncconf` disables that peer's
keepalives. The peer stays configured.
```bash
wg syncconf wg0 <(wg-quick strip wg0)
```
### Private keys loaded by `PreUp`
During `wg-quick up`, the file is applied with `wg addconf` after `PreUp` runs.
A private key loaded by the hook stays in place when the file omits `PrivateKey`.
```ini
[Interface]
PreUp = wg set %i private-key /etc/wireguard/%i.key
```
### Helper shell requirement
The `reresolve-dns` helper reads the current time from `EPOCHSECONDS`.
Run it with a Bash version that provides that variable.
## Peer configuration
### Incremental AllowedIPs
On Linux, prefix any CIDR in a peer's `wg set` `allowed-ips` list with `+` or `-`
to make the entire update incremental. Entries with `+` or no prefix are added
if absent; entries with `-` are removed if present.
A list with no prefixes replaces the peer's existing AllowedIPs.
```sh
wg set wg0 peer "$peer_public_key" allowed-ips +192.0.2.0/24,-198.51.100.0/24,203.0.113.0/24
```
Changes after `v1.0.20260223` add incremental AllowedIPs updates to the Windows
backend and let `wg` pass update flags to the FreeBSD kernel.
On FreeBSD, use a kernel that supports those flags.
Within one `[Peer]` block, repeated `AllowedIPs` entries contribute to the same
list; see the peer-state reference for the configuration example.
### Endpoint hostname retries
`WG_ENDPOINT_RESOLUTION_RETRIES` sets the retry count for each peer's endpoint
hostname. `wg` retries non-permanent resolution failures with an increasing
delay, defaults to 15 retries, and accepts `infinity` for unlimited retries.
```sh
WG_ENDPOINT_RESOLUTION_RETRIES=3 wg set wg0 peer "$peer_public_key" endpoint vpn.example.net:51820
```
## `wg-quick` configuration
### Configuration lookup and interface names
When given an interface name, `wg-quick` checks `/etc/wireguard/INTERFACE.conf`
first, then any distribution-specific search paths.
For `wg-quick up wg0`, `/etc/wireguard/wg0.conf` is checked first.
Names matching `[a-zA-Z0-9_=+.-]{1,15}` are accepted: `vpn+lab.conf` is valid for
the interface `vpn+lab`.
On Linux, `wg-quick up` supplies the name through `ip link add dev`, allowing
interface names that match `ip link` keywords.
### Hashes in hooks
The shell interprets `#` in `PreUp`, `PostUp`, `PreDown`, and `PostDown`.
Quoted or escaped hashes reach the command as literal characters, and shell
comments still work.
```ini
[Interface]
PostUp = printf '%s\n' 'wg#ready' # Log the interface status
```
### DNS settings
Multiple `DNS` lines are accepted in `[Interface]`. IP addresses supply DNS
servers; hostnames supply DNS search domains.
```ini
[Interface]
DNS = 192.0.2.53
DNS = vpn.example.net
```
On Linux, when the `resolvconf` executable is a symlink, `wg-quick` registers
`DNS=` settings under the plain interface name. A stale
`/etc/resolvconf/interface-order` file can no longer introduce a legacy interface
prefix after a migration to the systemd resolver.
On OpenBSD, `wg-quick` uses `resolvd(8)` to apply tunnel DNS settings.
## Linux networking and startup ordering
### Automatic MTU and IPv4 default-route setup
When selecting an MTU automatically, Linux `wg-quick` bases the tunnel MTU on
the smallest MTU it finds. A lower-MTU path can determine the tunnel setting
when paths differ.
During IPv4 default-route setup, Linux `wg-quick` writes
`net.ipv4.conf.all.src_valid_mark=1` only if the current value differs.
This step can succeed in a network namespace that blocks sysctl writes when
the setting is already `1` there.
### DHCP and the example kill switch
DHCP clients using `PF_PACKET` sockets can still send traffic with the
`wg-quick` example `iptables` kill switch active: those sockets bypass
Netfilter and its `OUTPUT` rules.
### Dependent systemd units
Enabling a `wg-quick@.service` instance links it into `wg-quick.target` and
orders its startup before the target. In a dependent unit, use `Wants=` and
`After=` to pull in the target and wait for linked instances' start jobs to finish.
```ini
[Unit]
Wants=wg-quick.target
After=wg-quick.target
```
## Output, diagnostics, and C integration
### Key visibility
Formatted `wg show` output prints private and preshared keys as `(hidden)`
unless `WG_HIDE_KEYS=never`. The tab-separated `wg show wg0 dump` includes
private and preshared key values; treat its output as secret.
### Color and debug messages
`WG_COLOR_MODE=always` forces ANSI colors; `WG_COLOR_MODE=never` disables them.
With `auto`, an unset value, or an unrecognized value, `wg` uses color only when
writing to a terminal.
Userspace WireGuard implementations conventionally enable verbose logging
when started with `LOG_LEVEL=verbose` in their environment.
On OpenBSD and FreeBSD, run `ifconfig wg0 debug` to enable WireGuard debug
messages for `wg0`, then read them with `dmesg`.
### Embeddable library endpoint storage
The embeddable C library exposes a named `wg_endpoint` union, allowing C callers
to declare endpoint storage independently of a peer structure.