WireGuard for NetBSD
ozaki-r@netbsd.org
AsiaBSDCon 2019 NetBSD BoF
21 March 2019
WireGuard
Implementations of WireGuard
WireGuard for NetBSD
WireGuard for NetBSD (cont.)
Usage
# Create and setup an interface�ifconfig wg0 create�ifconfig wg0 inet 10.0.0.1/24�# Generate a pair of private and pubkey keys�wg-keygen > ./privkey�cat ./privkey | wg-keygen --pub > ./pubkey�# Configure the interface�wgconfig wg0 set private-key ./privkey�wgconfig wg0 set listen-port 52428�# Add a peer�wgconfig wg0 add peer peer0 "2iWFzywbDvYu2gQW5Q7/z/g5/Cv4bDDd6L3OKXLOwxs=" --endpoint=192.168,0.2:52428 --allowed-ips=10.0.0.0/24�# Try to send packets to the peer�ping 10.0.0.2�# Delete the peer�wgconfig wg0 delete peer peer0
Usage of wg-userpace (WIP)
# Create an instance�wg-userspace 0 create�# Set up interfaces and WireGuard �wg-userspace 0 ifconfig wg0 inet 10.0.0.1/24�wg-userspace 0 wgconfig wg0 set private-key ./privkey�wg-userspace 0 wgconfig wg0 set listen-port 5242�...�# Destroy the instance�wg-userspace 0 destroy
Internals of the in-kernel implementation
IP
UDP
wg0
wm0
WireGuard
port X
User traffic
Handshake
messages
Data
messages
NetBSD kernel
Messages over UDP packets
{Enc,Dec}rypt
Internals of the userspace implementation
IP
UDP
wg0
Handshake & Data
messages
rump kernel (just a process)
NetBSD kernel
tun0
User traffic
port X
libc
(socket)
WireGuard
{Enc,Dec}rypt
User traffic
Sync IP addresses, etc.
Communications over sockets/fd
Current status
Acknowledgements
Thanks!