Skip to content

Commit 9714161

Browse files
committed
Fix: cleanup rdns value when dig fails to resolve (network error)
1 parent 4bc794a commit 9714161

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

func/ip.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ is_ip_rdns_valid() {
3131
local awk_ip=$(echo $network_ip | sed 's|\.|/\&\&/|g')
3232
local rev_awk_ip=$(echo $awk_ip | rev)
3333

34-
[ -z "$rdns" ] && local rdns=$(dig +short -x $ip | head -n 1 | sed 's/.$//')
34+
if [ -z "$rdns" ]; then
35+
local rdns=$(dig +short -x "$ip" | head -n 1 | sed 's/.$//') || unset rdns
36+
fi
3537

3638
if [ ! -z "$rdns" ] && [ ! $(echo $rdns | awk "/$awk_ip/ || /$rev_awk_ip/") ]; then
3739
echo $rdns

0 commit comments

Comments
 (0)