From 5681e2bcbd6864dfba753aa4a9f240d30ac085b6 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 17 Aug 2022 14:05:25 +0200 Subject: [PATCH] netcardconfig: avoid suggesting default gateway if a default route exists already When multiple NICs are present, a default gateway might exist already, while adding another default gateway then fails and is confusing. So instead let's present an empty input text dialog then, so the defaults should work fine. See https://github.com/grml/grml-terminalserver/issues/4 --- sbin/netcardconfig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sbin/netcardconfig b/sbin/netcardconfig index 8916642..4a3cd71 100755 --- a/sbin/netcardconfig +++ b/sbin/netcardconfig @@ -410,7 +410,12 @@ configiface() { $DIALOG --inputbox "$MESSAGE8 $DV" 10 45 "${BC:-${IP%.*}.255}" 2>"$TMP" || bailout 1 read -r BC <"$TMP" ; rm -f "$TMP" - $DIALOG --inputbox "$MESSAGE9" 10 45 "${DG:-${IP%.*}.1}" 2>"$TMP" + # if we already have a default route, don't suggest to add another one as that might fail + __default_gw="" + if ! route -en | grep -q '^0.0.0.0' ; then + __default_gw="${DG:-${IP%.*}.1}" + fi + $DIALOG --inputbox "$MESSAGE9" 10 45 "${__default_gw}" 2>"$TMP" read -r DG <"$TMP" ; rm -f "$TMP" if [ -f "/etc/resolv.conf" ]; then -- 2.1.4