1 min to read
Script to validate DNS, NTP and Logging servers across NSX-T components

Introduction:
Recently, the straw that broke the camels back was when I needed to validate hostname/dns/ntp and logging server settings across a customers brownfield NSX-T environment. They had multiple sites which were all separate deployments. The bash script below will pull the following configuration settings from Managers and Edge Transport Nodes:
- Hostname
- DNS Servers
- NTP Servers
- Logging Servers
Script:
#!/bin/bash
#Get commands to run against specified hosts
COMMANDS=("get hostname" "get name-servers" "get ntp-servers" "get logging-servers")
#Manager and edge TN IPs below
HOSTS=("10.10.50.14" "10.10.50.16" "10.10.50.17" "10.10.50.18" "10.10.50.19")
#Credentials for hosts listed above
USERNAMES=("admin")
PASSWORDS=("adminpasshere")
for HOSTNAME in ${HOSTS} ; do
ssh-keygen -R ${HOSTS}; ssh-keyscan ${HOSTS} >> ~/.ssh/known_hosts
done
for HOSTNAME in ${HOSTS} ; do
ssh-keygen -R ${HOSTS}; ssh-keyscan ${HOSTS} >> ~/.ssh/known_hosts
done
for i in ${!HOSTS[*]} ; do
echo "------------------------------------"
echo ${HOSTS[i]}
for j in ${!COMMANDS[*]}; do
echo "${COMMANDS[j]}"
sshpass -p ${PASSWORDS} ssh -l ${USERNAMES} ${HOSTS[i]} "${COMMANDS[j]}"
done
echo "------------------------------------"
done
Output:
------------------------------------
10.10.50.14
get hostname
kxk-nsx01
get name-servers
192.168.1.254
get ntp-servers
192.168.1.254
get logging-servers
192.168.1.60 proto udp level debug
------------------------------------
------------------------------------
10.10.50.16
get hostname
kxk-edge01
get name-servers
192.168.1.254
get ntp-servers
192.168.1.254
get logging-servers
------------------------------------
------------------------------------
10.10.50.17
get hostname
kxk-edge02
get name-servers
192.168.1.254
get ntp-servers
192.168.1.254
get logging-servers
------------------------------------