Skip to content

Commit

Permalink
netcardconfig: avoid suggesting default gateway if a default route ex…
Browse files Browse the repository at this point in the history
…ists 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 grml/grml-terminalserver#4
  • Loading branch information
mika committed Aug 17, 2022
1 parent ab3ad11 commit 5681e2b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sbin/netcardconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5681e2b

Please sign in to comment.