New contrib/ Utility: wg-config

Jason A. Donenfeld Jason at zx2c4.com
Fri Dec 9 11:46:26 CET 2016


I guess. But keep in mind that wg-config is an _example_, not
something meant to be standardized. It's a tiny bash script! I'd hate
for my terrible bash script to become some kind of "standard". It's
meant mostly as inspiration for people who want to build real tools,
which is why it's in the examples directory. (I added the makefile
install target specifically for Christian, I suppose, since he seems
to have some wild ideas of his own...)

But here, I added CONFIG_FILE_CONTENTS, so you don't need an extra
file. What a hack. But it actually works pretty cleanly.

/etc/wireguard/wg-vpn-gateway.env:

       CONFIG_FILE_CONTENTS="
       [Interface]
       PrivateKey = 6JiA3fa+NG+x5m6aq7+lxlVaVqVf1mxK6/pDOZdNuXc=

       [Peer]
       PublicKey = 6NagfTu+s8+TkEKpxX7pNjJuTf4zYtoJme7iQFYIw0A=
       AllowedIPs = 0.0.0.0/0
       Endpoint = demo.wireguard.io:29912
       "

       ADDRESSES=( 10.200.100.2/32 )

       post_add() {
               printf 'nameserver 10.200.100.1' | cmd resolvconf -a
"$INTERFACE" -m 0
       }
       post_del() {
               cmd resolvconf -d "$INTERFACE"
       }

Run to flip on the VPN:
# wg-config add wgvpn0 --env-file=/etc/wireguard/wg-vpn-gateway.env
Run to flip off the VPN:
# wg-config del wgvpn0 --env-file=/etc/wireguard/wg-vpn-gateway.env


More information about the WireGuard mailing list