summaryrefslogtreecommitdiffstats
path: root/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage4
diff options
context:
space:
mode:
Diffstat (limited to 'builder/modules.d/slx-network/scripts/udhcpc-trigger.stage4')
-rwxr-xr-xbuilder/modules.d/slx-network/scripts/udhcpc-trigger.stage46
1 files changed, 5 insertions, 1 deletions
diff --git a/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage4 b/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage4
index b4dfeafa..d7009dc6 100755
--- a/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage4
+++ b/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage4
@@ -66,7 +66,11 @@ case "$1" in
ip addr add "$ip/$(ipcalc -s -p "$ip" "$subnet" | sed s/.*=//)" dev "$interface"
# Set default route, if given
if [ -n "$router" ]; then
- ip route replace default via "$router"
+ # Only replace route if it's the same interface as the current default route, or we don't have any
+ current="$( ip route show | awk '{ if ($1 == "default") {print $5; exit 0}}' )"
+ if [ -z "$current" ] || [ "$interface" = "$current" ]; then
+ ip route replace default via "$router"
+ fi
fi
# get domain, hostname and thus fqdn from DNS