[WireGuard] Using Network Namespaces for Default Routing

Jason A. Donenfeld Jason at zx2c4.com
Mon Jul 25 12:07:06 CEST 2016


Hey guys,

I had a small idea over the weekend of using network namespaces with
wireguard for controlling the default route, as a substitute for
0/1,128/1 or rule-based routing. I collected my thoughts on this here:
https://www.wireguard.io/netns/ with the relevant part in this section
https://www.wireguard.io/netns/#the-new-namespace-solution .

The basic gist is as follows:

# ip netns create physical
# ip link set eth0 netns physical
# iw phy phy0 set netns name physical
# ip -n physical link add wg0 type wireguard
# ip -n physical set wg0 netns 1
# ip netns exec physical dhcpcd wlan0
# ip netns exec physical wpa_supplicant -iwlan0
-c/etc/wpa_supplicant/wpa_supplicant.conf
# ip -n physical addr add 192.168.12.52/24 dev eth0
# wg setconf wg0 /etc/wireguard/wg0.conf
# ip addr add 10.2.4.5/32 dev wg0
# ip route add default dev wg0
# ip link set wg0 up

But there's a lot more detail on the page listed above. Interested in
hearing your feedback!

Regards,
Jason


More information about the WireGuard mailing list