[PATCH] wg-quick: Unset the DNS first, then delete the WireGuard interface.

Colin Finck mail at colinfinck.de
Thu Mar 14 12:56:12 CET 2019


This prevents an "Unknown interface 'wg0': No such device" error on the command line.

Signed-off-by: Colin Finck <mail at colinfinck.de>
---
 src/tools/wg-quick/freebsd.bash | 2 +-
 src/tools/wg-quick/linux.bash   | 2 +-
 src/tools/wg-quick/openbsd.bash | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/tools/wg-quick/freebsd.bash b/src/tools/wg-quick/freebsd.bash
index e83dbef..3b2d95b 100755
--- a/src/tools/wg-quick/freebsd.bash
+++ b/src/tools/wg-quick/freebsd.bash
@@ -420,8 +420,8 @@ cmd_down() {
 	[[ " $(wg show interfaces) " == *" $INTERFACE "* ]] || die "\`$INTERFACE' is not a WireGuard interface"
 	execute_hooks "${PRE_DOWN[@]}"
 	[[ $SAVE_CONFIG -eq 0 ]] || save_config
-	del_if
 	unset_dns
+	del_if
 	execute_hooks "${POST_DOWN[@]}"
 }
 
diff --git a/src/tools/wg-quick/linux.bash b/src/tools/wg-quick/linux.bash
index 84643c4..d3d4fb0 100755
--- a/src/tools/wg-quick/linux.bash
+++ b/src/tools/wg-quick/linux.bash
@@ -295,8 +295,8 @@ cmd_down() {
 	[[ " $(wg show interfaces) " == *" $INTERFACE "* ]] || die "\`$INTERFACE' is not a WireGuard interface"
 	execute_hooks "${PRE_DOWN[@]}"
 	[[ $SAVE_CONFIG -eq 0 ]] || save_config
-	del_if
 	unset_dns
+	del_if
 	execute_hooks "${POST_DOWN[@]}"
 }
 
diff --git a/src/tools/wg-quick/openbsd.bash b/src/tools/wg-quick/openbsd.bash
index 9996162..d701ae1 100755
--- a/src/tools/wg-quick/openbsd.bash
+++ b/src/tools/wg-quick/openbsd.bash
@@ -414,8 +414,8 @@ cmd_down() {
 	fi
 	execute_hooks "${PRE_DOWN[@]}"
 	[[ $SAVE_CONFIG -eq 0 ]] || save_config
-	del_if
 	unset_dns
+	del_if
 	execute_hooks "${POST_DOWN[@]}"
 }
 
-- 
2.17.1.windows.2



More information about the WireGuard mailing list