[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
# ip -n physical addr add dev eth0
# wg setconf wg0 /etc/wireguard/wg0.conf
# ip addr add 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!


More information about the WireGuard mailing list