#!/bin/bash queryHost=foo.domain.local host=10.0.0.1 ldapUser=foo ldapPass=bar for a in $(ldapsearch -LLL -x -H ldap://$host:3268 -D "$ldapUser" -w "$ldapPass" -b "ou=Domain Controllers,dc=domain,dc=local" "(sAMAccountType=805306369)" name|egrep '^name:'| awk '{print $2}' ); do echo -n -e "$a: \t" if (dig @$a A $queryHost > /dev/null 2>&1); then dig @$a A $queryHost | grep -v -e '^;' -e '^$' | awk '{print $5}' else echo "DNS Dienst nicht erreichbar" fi echo "---------------------------" done;