mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
47 lines
601 B
Bash
Executable file
47 lines
601 B
Bash
Executable file
#! /bin/sh -e
|
|
#
|
|
# Returns a list of IP addresses associated with hostname $1.
|
|
|
|
sheesh=`dig +noauthor +noaddit $1 a |
|
|
|
|
awk '
|
|
BEGIN {
|
|
name = "'$1'"
|
|
|
|
if ( name ~ /^[0-9][0-9]*\.[0-9][0-9]*/ )
|
|
# An address, not a name.
|
|
print name
|
|
|
|
name = name "."
|
|
}
|
|
|
|
/^;; ANSWER/ {
|
|
getline
|
|
|
|
# First reduce CNAMEs.
|
|
while ( $4 == "CNAME" )
|
|
{
|
|
name = $5
|
|
getline
|
|
}
|
|
|
|
# Now pick off the addresses.
|
|
while ( $1 == name )
|
|
{
|
|
print $5
|
|
getline
|
|
}
|
|
|
|
++num_answers
|
|
}
|
|
|
|
END {
|
|
if ( num_answers == 0 )
|
|
{
|
|
print "no DNS answers to query for", name >"/dev/stderr"
|
|
exit 1;
|
|
}
|
|
}
|
|
'`
|
|
|
|
echo "$sheesh" | sort -u
|