trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
host=$1
-addr=$(getent hosts $host | awk '{print $1}')
-h=$(getent hosts $addr | awk '{print $2}')
-echo ${h%%.*}
+# ||: because if we are using 2+ resolvers, 1 may fail, causing error, but we still get
+# a valid address and we just use that
+addr=$(host $host | sed -rn 's/^\S+ has address //p;T;q' ||:)
+h=$(host $addr)
+h=${h##* }
+echo $h