It's a very crude script that allows two machines that share a possibly untrusted network (e.g. WiFi) to connect to each-other and establish a secure tunnel.
The assumption is both machines can see each-other via multicast DNS, and can send UDP traffic between each-other. If you're using a WiFi network that isolates its clients, you're out of luck.
Firstly, you must enable mDNS
for resolving hosts, something like:
hosts: files mdns4_minimal [NOTFOUND=return] dns
in your /etc/nsswitch.conf
will get you started.
You'll also need something like libnss-mdns
installed.
We define a configuration file; /etc/wg0.conf
with the settings for our peer network:
INTERFACE=wg0
SUBNET_IP=2001:db8:aaaa:bbbb:: # pro-tip, generate a ULA for this!
SUBNET_SZ=64
LISTEN_PORT=51820
PERSISTENT_KEEPALIVE=60
You need to generate keypairs for all your nodes, then create a file for each node in /etc/wg.peers
:
ip=2001:db8:aaaa:bbbb::1
pubkey=q2DV2U45a5JLzEFScIZLs7CMeV0kZePOl8n15phACrki7Vha
Keep the ip
s unique!
The vpn-up.sh
script is run each minute from cron
. (Yes, very hacky!)
* * * * * root /usr/local/sbin/vpn-up.sh >> /tmp/vpn.log 2>&1