wgtool (WireGuard helper CLI)
wgtool streamlines creating and validating WireGuard configs, and generating a ready-to-paste Zion peer block.
Features
- Generate WireGuard configs with sensible defaults
- Validate single configs or all .conf files in a directory
- Print a Zion-ready [Peer] snippet for adding new nodes
- Generate private keys (derive public key with
wg pubkey)
Commands
generate: Create a config and write keysvalidate: Lint a config file or all.conffiles in a directoryzion-peer: Print a[Peer]block for Zion’swg0.confkeys: Print a private keyversion: Show tool version
Defaults and endpoints
- Adds one default peer in generated configs:
- Zion (central server)
- PublicKey:
2ztJbrN1x1NWanzPGLiKL19ZkdOhm5Y7WeKEWBT5cyg= - Endpoint:
ugh.im:51820 - AllowedIPs:
wg_only:10.8.0.0/24full_tunnel:0.0.0.0/0, ::/0
- PersistentKeepalive:
25
- PublicKey:
- Zion (central server)
generate
Create a config into wireguard_configs/ and output keys alongside it. Missing flags are prompted interactively unless --yes is used.
Flags:
--hostnameNode name (e.g.,aza)--ipNode IP in10.8.0.x--interfaceInterface name (defaultwg0)--routingwg_only|full_tunnel(defaultwg_only)--outOutput directory (defaultwireguard_configs)--forceOverwrite without prompt--yesNon-interactive (assume yes)
Examples:
./wgtool generate
./wgtool generate --hostname aza --ip 10.8.0.30 --interface wg0 --routing wg_only --out wireguard_configs --yes
./wgtool generate --hostname aza --ip 10.8.0.30 --routing full_tunnel --yes
Outputs:
wireguard_configs/wg0.confwireguard_configs/<hostname>_private.key- Derive public key:
echo "<PrivateKey>" | wg pubkey
validate
Validate a config file or every .conf in a directory.
Flags:
--targetPath to a file or directory
Examples:
./wgtool validate --target wireguard_configs/wg0.conf
./wgtool validate --target wireguard_configs
Checks include:
- Presence of
[Interface] PrivateKeyand CIDRAddress- Peer
PublicKeyformat AllowedIPsas valid CIDRs
zion-peer
Print a [Peer] block to add into Zion’s /etc/wireguard/wg0.conf for a new node.
Flags:
--nameNode name--pubNode public key (44-char base64 ending with=)--ipNode IP in10.8.0.x(host address)
Example:
./wgtool zion-peer --name aza --pub ABCDEFG...= --ip 10.8.0.30
keys
Generate and print a private key.
Example:
./wgtool keys
# derive pub
echo "<PrivateKey>" | wg pubkey
Quick start
- Create a config and keys
./wgtool generate --hostname mynode --ip 10.8.0.30 --yes
- Validate the config
./wgtool validate --target wireguard_configs/wg0.conf
- Give Zion your peer details
./wgtool zion-peer --name mynode --pub $(echo "<PrivateKey>" | wg pubkey) --ip 10.8.0.30
- Install and enable (on your node)
sudo cp wireguard_configs/wg0.conf /etc/wireguard/
sudo chmod 600 /etc/wireguard/wg0.conf
sudo systemctl enable --now wg-quick@wg0
Notes:
- IPs are enforced in the
10.8.0.xrange. - In
full_tunnelmode DNS is set to1.1.1.1, 8.8.8.8. - Overwrites are blocked unless
--forceor confirmed interactively.
Description
Languages
Go
50.1%
Shell
49.9%