Wireguard problem - ifdown wg0 does not restore default route


I am aware wireguard is still under heavy development, but I realized a problem which I am not sure is either a bug or a feature.

I tested to connect my omnia to an external wireguard “server” to route all my traffic through the vpn as a test. If you set up wireguard and set it to non-auto in the config, you can enable and disable it with ifup/ifdown wg0. While ifup sets up the new routes correctly, ifdown does not restore the default route, which leaves the omnia without wan access.

Enabling/Disabling wireguard through the UI does not have this “bug”, because the UI resets the networking completely, I believe, which recalculates the default route, I believe.

Due to the sparse documentation about wireguard, I am not sure this is a bug or a feature. Also due to missing documentation about the UCI implementation of the wireguard, I don’t know yet how to enable post-up/post-down scripts.

Any ideas how to restore the default routes automatically are welcome.

iproute2 commands, e.g. (cited IPs are samples for this node and unlikely to match your setup)

ip r d via dev wg0
ip l d wg0

But this does not solve the “automatic” part, does it?


My understanding of what happens when managing wg via LuCI

proto_wireguard_teardown() {
	local config="$1"
	ip link del dev "${config}" >/dev/null 2>&1