check DNS resolution validity in batch
search cancel

check DNS resolution validity in batch

book

Article ID: 423252

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

It is very important to check DNS resolution validity.  In KB 423200, there is a script to check DNS resolution. That is a good script, but it can only check one FQDN/IP address . We need a script to check multiple FQDNs in batch .

Environment

vCenter  Server

Esxi

and Linux 

Cause

Found the  advanced_check_dns_batch.sh file in attachment.

 

1) It compares the result of nslookup and getent, if the results are different, it means an inconsistency is found.

 

2) This script also compares the reverse resolution ( IP to FQDN) .

Resolution

In attachment, there is an advanced_check_dsn_batch.txt file. 

The syntax is:

      ./advanced_check_dsn_batch.sh  a.txt

In a.txt, there are multiple hostnames(FQDN)

 

Example:

 a) In a.txt file, 

host1.example.com
host2.example.com
host3.example.com
host77.example.com
 

 

b) Run the script: 

# ./advanced_check_dsn_batch.sh  a.txt
HOSTNAME                  SYSTEM IP            DNS IP           STATUS
-------------------------------------------------------------------------------
host1.example.com       192.168.99.1         192.168.99.1          OK
   ↳ Reverse Check: Sys[host1.example.com] | DNS[host1.example.com]

host2.example.com       192.168.99.2         192.168.99.2          OK
   ↳ Reverse Check: Sys[host2.example.com] | DNS[host2.example.com]

host3.example.com       192.168.99.3         192.168.99.3           OK
   ↳ Reverse Check: Sys[host3.example.com] | DNS[host3.example.com]

host77.example.com           --               127.0.0.1#53     MISMATCH

 

  host1,host2,host3 are OK, but host77 is NG.

 

 

Tips:

   In some cases,  DNS server may return more than 1 IP addresses for a single FQDN. Only 1 IP address is correct, and other IP addresses are invalid.

   For that case, run  this script for multiple times, it may catch the invalid IP address.

   But if the script is executed only once , and the correct IP address is returned, we may missed the DNS  resolution issue. So do please run the script for multiple times. 

Attachments

advanced_check_dns_batch.sh.txt get_app