print_config_title 'CHECK DNS CONFIG' # Test resolver for name_to_resolv in ${NAMES_TO_RESOLV_AND_PING[@]}; do echo -e "Check resolve ${BLUE}${name_to_resolv}${NC}" # Check if name is resolved # We use nslookup because return code can be used in our case nslookup ${name_to_resolv} &>/dev/null # Return Code RC=$? # Resolving failed if [ $RC -ne 0 ] then RESOLV_FAILED="${RESOLV_FAILED} ${name_to_resolv}" echo -e "${RED}Resolve ${name_to_resolv} FAILED : check KO${NC}\n" # Resolving succeded else echo -e "${GREEN}Resolve ${name_to_resolv} SUCCEDED : check OK${NC}\n" fi done # Check /etc/resolv.conf for resolver in ${RESOLVERS[@]} do echo -e "Check in /etc/resolv.conf if this name server is present : ${BLUE}${resolver}${NC}" # Check /etc/resolv.conf grep -qi "^nameserver[[:space:]]*${resolver}[[:space:]]*$" /etc/resolv.conf # Return Code RC=$? # Resolver is NOT in the file if [ $RC -ne 0 ] then RESOLVER_NOT_IN_ETC_RESOLVCONF="${RESOLVER_NOT_IN_ETC_RESOLVCONF} ${resolver}" echo -e "${RED}${resolver} is NOT in /etc/resolv.conf : check KO${NC}\n" # Resolver is in the file else echo -e "${GREEN}${resolver} is in /etc/resolv.conf : check OK${NC}\n" fi done # Check if IP recorded in DNS for ip in ${LOCALES_IP_WITHOUT_LOOPBACK[@]} do echo -e "Check if IP is recorded in DNS : ${BLUE}${ip}${NC}" # Check /etc/resolv.conf nslookup ${ip} &>/dev/null # Return Code RC=$? # IP NOT recorded in DNS if [ $RC -ne 0 ] then IP_NOT_RECORDED_IN_DNS="${IP_NOT_RECORDED_IN_DNS} ${ip}" echo -e "${RED}${ip} is NOT recorded in DNS : check KO${NC}\n" # IP recorded in DNS else echo -e "${GREEN}${ip} is recorded in DNS : check OK${NC}\n" fi done # Check if hostname recorded in DNS (A and AAAA records) echo -e "Check if hostname is recorded in DNS : ${BLUE}A and AAAA records${NC}" # Check if record A is set in DNS for hostname nslookup -querytype=A $(hostname) &>/dev/null # Return Code RC=$? # If no 'A' DNS record for hostname if [ $RC -ne 0 ] then HOSTNAME_A_RECORD_NOT_IN_DNS=1 echo -e "${RED}Hostname is NOT recorded in DNS (A record) : check KO${NC}\n" # If 'A' DNS record for hostname exist else echo -e "${GREEN}Hostname is recorded in DNS (A record) : check OK${NC}\n" fi # Check if record AAAA is set in DNS for hostname nslookup -querytype=AAAA $(hostname) &>/dev/null # Return Code RC=$? # If no 'AAAA' DNS record for hostname if [ $RC -ne 0 ] then HOSTNAME_AAAA_RECORD_NOT_IN_DNS=1 echo -e "${RED}Hostname is NOT recorded in DNS (AAAA record) : check KO${NC}\n" # If 'AAAA' DNS record for hostname exist else echo -e "${GREEN}Hostname is recorded in DNS (AAAA record) : check OK${NC}\n" fi