Skip to main content

Scriptable shortcuts for managing Wireguard interfaces.

Project description

wgup

NOTE: This project is a very early work in progress. Features and documentation WILL be missing.

Scriptable shortcuts for managing WireGuard interfaces. Works with wg-quick to create common setups in seconds, while leaving room for more advanced configurations.

Features

  • wgup handles generation and management of keys
  • wgup handles IP address pool selection and assignment
    • Of course, you can still assign pools and IPs manually. wgup's automatic assignments will work around existing manual assignments.
  • wgup generates firewall rules and NATs
  • wgup supplements core WireGuard tools -- it does not replace them.

Dependencies

Note: Make sure packet forwarding on your system is enabled! If you're unsure, uncomment net.ipv4.ip_forward=1 and net.ipv6.conf.all.forwarding=1 in /etc/sysctl.conf.

wgup requires Python >= 3.10, which is almost certainly included in your distro.

Ubuntu (22.04,24.04) / Debian (11, 12): wireguard-tools

sudo apt install wireguard-tools

Fedora (39,40): wireguard-tools

sudo dnf install wireguard-tools

Arch Linux: wireguard-tools

sudo pacman -S wireguard-tools

Notes

  • wgup will never open a port on your firewall. To ensure that clients can connect, make sure your interfaces' ports are open to incoming UDP traffic.

  • wgup is opinionated. Certain things like the keepalive interval and the host machine's VPN address are defined by wgup. In the future I hope to provide defaults that work for most setups, while allowing customization.

  • wgup is agentless. If you reconfigure an interface or a peer, you will need to export and apply the configs before they will work.

  • wgup stores peer keys on the host. My reasoning is that these keys should only be used to identify the peer to the host. Keys should be unique to each interface<->peer connection, so if the host machine is compromised, its peers connections to other machines are not at risk.

  • wgup stores its configuration in ~/.wgup.

Usage

Help

Help (hopefully helpful) exists for wgup and all its subcommands, and may be a better TLDR than this README.

Use the -h or --help flag with any command for help.

wgup --help
wgup iface --help
wgup peer --help
wgup nat --help

Managing interfaces

The following creates a new interface called "wg0". Peers will be configured to connect to "vpn.example.com:51820".

wgup iface create wg0 --host vpn.example.com --port 51820

You may also specify IP address pools for the interface to use. If you leave them out, wgup will choose random private pools to reduce the chance of a conflict.

wgup iface create wg0 --cidr4 172.31.0.0/24 --cidr6 2001:db8::/64 --host vpn.example.com --port 51820

The machine hosting the interface will always be assigned the first IP address in the pool, both for IPv4 and IPv6.

To see the interface you just created:

wgup iface show wg0

To see all interfaces managed by wgup:

wgup iface ls

To modify an interface's parameters after creating it:

wgup iface set wg0 cidr4 172.31.1.0/24
wgup iface set wg0 cidr6 2001:db8::1/64
wgup iface set wg0 name wg1

To rekey an interface (generates new keys for the interface and all its peers):

wgup iface rekey wg0

To export an interface's config for use:

wgup iface export wg0  # exports configs to /etc/wireguard by default
wgup iface export wg0 --path /other/wireguard/config/directory

Managing peers

To create a new peer called "laptop":

wgup peer create wg0 laptop

As is the case with interfaces, you can also specify an IP address pool for the peer to use. Usually these are single addresses (/32 for IPv4, /128 for IPv6), but it is often desirable to route a pool of addresses to a peer in more advanced setups.

If you do not specify IP addresses, wgup will choose the next available ones.

wgup peer create wg0 laptop --cidr4 172.31.0.123/32 --cidr6 2001:db8::beef/32

To see the peer you just created:

wgup peer show wg0 laptop

To see all peers on "wg0":

wgup iface ls

To modify a peer's parameters after creating it:

wgup peer set wg0 laptop cidr4 172.31.0.5/32
wgup peer set wg0 laptop cidr6 2001:db8::cafe/32
wgup peer set wg0 laptop name cooler_laptop

To rekey a peer (generates new keys for this peer only):

wgup peer rekey wg0 laptop

To export a peer's config for use:

wgup peer export wg0 laptop  # prints to stdout by default
wgup peer export wg0 laptop --filename laptop_wg.conf

Managing NATs

NOTE: After making changes to NATs, you need to export peer configs again for the new or removed routes to take effect.

To NAT all traffic from "wg0" to the physical interface "eth0":

wgup nat create wg0 eth0 --cidr4 0.0.0.0/0 --cidr6 ::/0

You must include either an IPv4 or IPv6 destination (or both).

To remove an existing NAT:

wgup nat rm wg0 eth0 --cidr4 0.0.0.0/0

Licensing

wgup is Free and Open Source Software, and is released under the BSD 2-Clause license. (See LICENSE)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wgup-0.0.0a2.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wgup-0.0.0a2-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file wgup-0.0.0a2.tar.gz.

File metadata

  • Download URL: wgup-0.0.0a2.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for wgup-0.0.0a2.tar.gz
Algorithm Hash digest
SHA256 d46565f8e3ef186081a580098b64fee9f4c0e183c0f42e5cdfc030bc2e57d671
MD5 72a5c53f909d9fa64218011a850b1d7b
BLAKE2b-256 08cac45a2b273823ced0a5838f011a66776ffaef1bf5d10ffa67d89aede92d6c

See more details on using hashes here.

File details

Details for the file wgup-0.0.0a2-py3-none-any.whl.

File metadata

  • Download URL: wgup-0.0.0a2-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for wgup-0.0.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d26d1b07fe18d16fc36ad8664c5ba3f81eab5f0764ac876bfde2d7cd691795f
MD5 9d037402ffe272c383519a9ee340f45e
BLAKE2b-256 aac25b29365a76a03379e2793ab3fbb77a8441747540b093775a84c2f02d618f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page