From 9f10cc7e97cdaed137a2b536ef62307ebe184ff4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 11 Sep 2019 16:04:45 +0200 Subject: [dhcpc-busybox] Fix default route setting --- .../dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx') diff --git a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx index 955b8975..debe82a4 100755 --- a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx +++ b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx @@ -77,12 +77,16 @@ case "$1" in check_env "$1" mkdir -p "/run/dhcpc" # Set address on interface - ip addr add "$ip/$(ipcalc -s -p "$ip" "$subnet" | sed s/.*=//)" dev "$interface" + 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 dns_fqdn=$(busybox timeout -t 3 rdns "$ip") dns_short="${dns_fqdn%%.*}" @@ -98,7 +102,7 @@ case "$1" in : elif [ -n "$dns_fqdn" ]; then domain="${dns_fqdn#*.}" - + elif [ -n "$SLX_NET_DOMAIN" ]; then domain="$SLX_NET_DOMAIN" fi -- cgit v1.2.3-55-g7522