Añadir 'ip2host.sh'
This commit is contained in:
parent
5d86545274
commit
8a186d252b
22
ip2host.sh
Normal file
22
ip2host.sh
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo "You must specify a filename to read from"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
if [ ! -f "$1" ]
|
||||||
|
then
|
||||||
|
echo "File $1 does not exist or is not a file"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
while read ip n
|
||||||
|
do
|
||||||
|
# Uncomment following to use /etc/hosts
|
||||||
|
# name=$(awk -v ip=$ip '$1 ~ ip{print $2}' /etc/hosts)
|
||||||
|
# Uncomment following to use nslookup
|
||||||
|
# name=$(nslookup $ip| grep "name ="|sed 's/.*=//')
|
||||||
|
# Uncomment following line to use dig (thanks to Charles Duffy)
|
||||||
|
#name=$(dig +short -x $ip)i
|
||||||
|
resolvedIP=$(dig +short -x "$ip")
|
||||||
|
[[ -z "$resolvedIP" ]] && echo "$ip" lookup failure || echo "$ip" resolved to "$resolvedIP"
|
||||||
|
done < $1
|
Loading…
Reference in New Issue
Block a user