From 3b4aea824531b73848b664c269ba7a205e48fff1 Mon Sep 17 00:00:00 2001 From: borekon Date: Thu, 27 Oct 2022 11:32:56 +0000 Subject: [PATCH] Option to select custom nameserver --- host2ip.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/host2ip.sh b/host2ip.sh index 4f99ec9..f75bbab 100755 --- a/host2ip.sh +++ b/host2ip.sh @@ -17,6 +17,11 @@ do # name=$(nslookup $ip| grep "name ="|sed 's/.*=//') # Uncomment following line to use dig (thanks to Charles Duffy) #name=$(dig +short -x $ip)i + if [ -z "$2"] + then resolvedIP=$(dig +short "$ip") + else + resolvedIP=$(dig +short "$ip" "$2") + fi [[ -z "$resolvedIP" ]] && echo "$ip" lookup failure || echo "$ip" resolved to "$resolvedIP" done < $1