diff options
Diffstat (limited to 'modules.d/slx-network/scripts/udhcpc-trigger.stage4')
-rwxr-xr-x | modules.d/slx-network/scripts/udhcpc-trigger.stage4 | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/modules.d/slx-network/scripts/udhcpc-trigger.stage4 b/modules.d/slx-network/scripts/udhcpc-trigger.stage4 index c2ea566a..5c02190b 100755 --- a/modules.d/slx-network/scripts/udhcpc-trigger.stage4 +++ b/modules.d/slx-network/scripts/udhcpc-trigger.stage4 @@ -59,6 +59,15 @@ check_env() { fi } +reverse_lookup() { + [ -z "$1" ] && return + timeout 3 nslookup "$1" | awk '{ + if ($2 == "name") { print gensub("\\.$", "", 1, $4); exit; } + if ($1 == "Name:") { ok = 1 } + if (ok && $1 == "Address") { print gensub("\\.$", "", 1, $4); exit; } + }' +} + case "$1" in bound|renew) check_env "$1" @@ -74,7 +83,7 @@ case "$1" in fi # get domain, hostname and thus fqdn from DNS - dns_fqdn=$(busybox timeout 3 rdns "$ip") + dns_fqdn=$( reverse_lookup "$ip" ) dns_short="${dns_fqdn%%.*}" # check if it is fqdn if [ "$dns_fqdn" == "$dns_short" ]; then |