Skip to main content

genwg

genwg is a wireguard and isc bind9 configuration generator with faketcp support and system resolver awareness.

features

  • wireguard "server" and "client" peer configuration generation.
  • allowing peers to utilize faketcp via udp2raw. (linux and android only)
  • android support for upd2raw without wg-quick's PreUp/PreDown hooks which do not exist in the android implementation.
  • generation of local plug and play bind9 A and PTR zones that reference the client peers for querying a list of all clients via dig axfr .local_zone @<ip.of.server.iface> and for seamless DNS resoluton via resolv.conf search.
  • allowing clients to incorporate the server's recursive DNS resolver into their local bind9 instance so that they get to keep their local zones while forwarding the root zone requests to the wireguard server to prevent leaks. (linux only)
  • yaml dump of the state after execution.

as Termux and alike do not have udp2raw packaged, you can find a build script and a prebuilt aarch64 elf binary.

installation

git clone --depth=1 https://github.com/gottaeat/genwg
cd genwg/
pip install .

configuration

specification

servers

key necessity description
name required str name for the interface
priv optional str wireguard private key for the server peer, will be generated if none provided
ip required str public ip address or the FQDN of the wireguard server peer
port required int port for the server peer to listen on
net required str vpn subnet in cidr notation
mtu required int mtu value for the interface: max 1340 for faketcp and 1460 for udp
extra_address optional str extra /32's to be appended to the Address line of the server peer and to the AllowedIPs of the clients that opted in
extra_allowed optional str extra non-/32 v4's to be added to the AllowedIPs of the clients in the configuration of the client itself
named optional look below
udp2raw optional look below

WARNING: if the same v4 that resides within extra_allowed of a server exist in the extra_allowed of the client, this network will not be added to that client's network, and when dumping back the yaml, this v4 will be removed from the server's extra_allowed.

WARNING 2: as the static routes installed for faketcp wrapped tunnels, setting the endpoint to an FQDN is not possible.

named

key necessity description
hostname required str value to be set as the name for the .1 of the vpn subnet in A and PTR records
conf_dir required str path where named.conf on the server peer lives, e.g. /etc/bind

udp2raw

key necessity description
secret optional str udp2raw secret, will be generated if none provided
port required int port for udp2raw to listen on

clients

key necessity description
name required str name for the client peer, only matters when server configuration requested bind9 zones to be generated
priv optional str wireguard private key for the client peer, will be generated if none provided
wg_handled_dns optional bool if set to true, the DNS ini key will be added and set to the internal ip of the wireguard interface for wg-quick to handle it in the platform specific way
bind optional bool if set to true, client configuration will have PreUp and PreDown hooks added to it to have the root zone forwarded to the server peer
root_zone_file required if bind str path to the file that contains the root hints
udp2raw_log_path required if server.udp2raw str path to dump the udp2raw stdin and stderr
android optional str declare client an android device
wgquick_path required if android && server.udp2raw str path to the wg-quick binary
udp2raw_path required if android && server.udp2raw str path to the udp2raw binary

WARNING: doing wireguard over faketcp on android may require root privileges depending on your device firmware.

example

servers:
- name:  wg0
  ip: 1.1.1.1
  port: 51820
  net: 10.0.0.0/24
  mtu: 1420
  named:
    hostname: debian12
    conf_dir: /etc/bind
  extra_address:
    - 192.168.1.2/32
  clients:
    - name: myrouter
      append_extra: true
      extra_allowed:
        - 192.168.1.0/24
    - name: mylinuxdesktop
      bind: true
      root_zone_file: /var/named/zone/root-nov6
    - name: myphone

- name: wg0raw
  ip: 1.1.1.1
  port: 51821
  net: 10.0.1.0/24
  mtu: 1340
  extra_allowed:
    - 10.0.0.0/24
  named:
    hostname: debian12raw
    conf_dir: /etc/bind
  udp2raw:
    port: 6666
  clients:
  - name: corponetlaptop
    bind: true
    root_zone_file: /var/named/zone/root-nov6
    udp2raw_log_path: /var/log/udp2raw.log
  - name: myphone
    udp2raw_log_path: ./udp2raw.log
    android: true
    wgquick_path: /system/xbin/wg-quick
    udp2raw_path: /data/data/com.termux/files/home/udp2raw

- name: wg0guest
  ip: 1.1.1.1
  port: 51822
  net: 10.0.2.0/24
  mtu: 1420
  clients:
    - name: johnguest

usage

genwg -c /path/to/genwg.yml

Metadata

Release files for genwg 0.8.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for genwg 0.8.2
File Size Uploaded
genwg-0.8.2.tar.gz 23.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for genwg 0.8.2
File Interpreter ABI Platform
genwg-0.8.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 48.0 kB

Release files / genwg-0.8.2.tar.gz

Download URL genwg-0.8.2.tar.gz
Size 23.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c5ed2a0049c9ff881d6336136c482c6b3e09070990b23ac08fcfcbd81e50f9e5
BLAKE2b-256 checksum
How to use checksums
1e84ad813f87fa3fa64564a6863a5d7971a89d3f02d40527b63cfd76a6026a92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 1, 2025.

Transparency log

Release files / genwg-0.8.2-py2.py3-none-any.whl

Download URL genwg-0.8.2-py2.py3-none-any.whl
Size 24.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c49e2fa464ccd7026b15ee35ec5150ab8f73bb8ab934777360940d2598a0febb
BLAKE2b-256 checksum
How to use checksums
be0b24f9b1ca6805103fbf101a1a91e803f7cf36ffb703b510ec7da5ab4fc7b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 1, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.8.2 This release

2 release files

0.8.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page