wg-meta

An approach to add metadata to the main wireguard config, written in Perl.

Highlights

Installation

Probably the easiest way is through cpan: https://metacpan.org/release/Wireguard-WGmeta

Build from source

perl Makefile.PL
make test
make install

Using .deb package

sudo dpkg -i wg-meta_X.X.X.deb

Environment variables

Usage

Intended to use as command wrapper for the wg show and wg set commands. Support for wg-quickis enabled by default.

Please note that all attributes have to be specified in the wg set syntax, which means AllowedIPs becomes allowed-ips and so on.

sudo wg-meta show

# output
interface: wg0
  State: UP
  ListenPort: 51888
  PublicKey: +qz742hzxD3E5z5QF7VOvleVS1onavQpXBK3NdTh40g=

+peer: WG_0_PEER_A_PUBLIC_KEY
  Name: testero
  Alias: Dual_stack_peer1
  AllowedIPs: fdc9:281f:04d7:9ee9::1/128, 10.0.3.43/32
  endpoint: 147.86.207.49:10400  latest-handshake: >month ago  transfer-rx: 0.26 MiB  transfer-tx: 1.36 MiB

# Access using peer
sudo wg-meta set wg0 peer +qz742hzxD3E5z5QF7VOvleVS1onavQpXBK3NdTh40g= name Fancy_meta_name

# Access using alias
sudo wg-meta set wg0 some_alias description "Some Desc"

# Disable peer
sudo wg-meta disable wg0 some_alias

# Enable peer
sudo wg-meta enable wg0 +qz742hzxD3E5z5QF7VOvleVS1onavQpXBK3NdTh40g=

# Apply config
sudo wg-meta apply wg0

Under the hood

The main advantage is that this tool is not dependent on any other storage, metadata is stored inside the corresponding wgXX.conf file (Metadata is prefixed with #+):

[Interface]
#+Alias = some_alias
#+Description = Some Desc
Address = 10.0.0.7/24
ListenPort = 6666
PrivateKey = WEkEJW3b4TDmRvN+G+K9elzq52/djAXT+LAB6BSEUmM=

[Peer]
#+Name = Fancy_meta_name
PublicKey = +qz742hzxD3E5z5QF7VOvleVS1onavQpXBK3NdTh40g=
AllowedIPs = 0.0.0.0/0
Endpoint = wg.example.com

Development of this project is sponsored by OETIKER+PARTNER AG