Introducing SOC Insights for BloxOne Threat Defense: Boost your SOC efficiency with AI-driven insights to eliminate manual work and accelerate investigation and response times. Read the blog announcement here.

NIOS DNS DHCP IPAM

Reply

Script to run dig command against all grid members

Adviser
Posts: 9
7310     0

Seems that lately I've had to do some troubleshooting with discrepancies in DNS records across grid members.  I got tired of manually typing the dig command for each grid member.  I created a simple BASH shell script that runs the same query across all the grid members.  Works for forward and reverse lookups, IPv4 and IPv6 lookups.  You have to define your grid members inside the script.  Hopefully they don't change much.  Thought someone else might find this useful.

 

#!/bin/bash

# This script will run a dig command against your grid members
# so you can easily compare results between them.  You can specify
# dig options for forward and reverse lookups as well as IPv4 and
# IPv6 lookups.  Actually, you can use this to compare between any
# DNS servers, not just Infoblox appliances.  Added the time function
# in order to get the actual response time to the client.

# Define your Infoblox grid members here
# Data format is GRID_MEMBER_DISPLAY_NAME and IP_ADDRESS separated with a colon
# Each data pair is separated with a space
INTERFACE="ATL:10.11.12.21 BOS:10.11.12.18 DAL:10.11.12.7 DEN:10.11.12.114 SED:10.11.12.39 PORT:10.11.12.72 "


# Define regular expressions to validate IPv4 and IPv6 address format
IPv4_REGEX='^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'
IPv6_REGEX='^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$'

echo
echo
echo
echo
echo

echo -n "Enter the name or IP address of the host to query:  "
read QUERY

# Assume QUERY string is not an IP address until verified as such
# Old options were too brief
# OPTIONS="+noall +comments +question +answer +tries=1"
# Set forward query options here
OPTIONS="+tries=1"

# See if QUERY string is IPv4
# Set query options here
if [[ $QUERY =~ $IPv4_REGEX ]]; then
   # QUERY is a valid IPv4 address
   # Use the -x option in the dig command
   OPTIONS="+tries=1 -x"
fi

# See if QUERY string is IPv6
# Set query options here
if [[ $QUERY =~ $IPv6_REGEX ]]; then
   # QUERY is a valid IPv6 address
   # Use the -x option in the dig command
   OPTIONS="+tries=1 -x"
fi

echo
echo
echo
echo
echo

# Loop through all the grid members and run the dig command
for DATA in $INTERFACE; do
   NAME=`echo $DATA | cut -d":" -f1`
   IP=`echo $DATA | cut -d":" -f2`
   echo "*****************************************"
   echo "* RESULTS FOR INFOBLOX APPLIANCE AT $NAME"
   echo "*****************************************"
   echo "Response time:"
   echo -n "----------------"
   RESULT=`time dig $OPTIONS $QUERY @$IP`
   echo
   echo "$RESULT"
   echo
   echo
   echo
   echo
   echo
done

exit

Re: Script to run dig command against all grid members

New Member
Posts: 5
7310     0

Hi Clark i am Using Windows and MobaXterm , I Can Open Whatever needed Session and then use MultiExec to Excute Same Command on all Sessions , The screen is Splitted to and you only type command once and excuted on all Memebers 

Re: Script to run dig command against all grid members

Adviser
Posts: 321
7311     0

Re: Script to run dig command against all grid members

New Member
Posts: 6
7311     0

Clark,

 

I support cutovers where large DNS changes are implemented.

I create CSV files for the cutover.

Looking for a tool to run dig using a list or file of fqdn's and IP's to get both forward and reverse results.

 

Is this something you are familiar with?

 

Thanks

Re: Script to run dig command against all grid members

[ Edited ]
Adviser
Posts: 9
7311     0

This is something that could be easily scripted if you are using a Unix based system.  Can you give me an example of what you want the output to look like?

 

EDIT:  Thinking about your question more . . . may I assume the CSV file contains DNS record changes?  After the CSV file was uploaded to the grid master, it would be easy to create a script that would parse a copy of the CSV file and check each grid member to see if the changes were successful and propagated to each member.  The only issue is formatting the output to meet your needs.  Since the CSV file contains the expected output, you could have the script display only the discrepancies.  Or you could have all the results displayed and sort through them all.  This sounds like a fun project for next week.

Re: Script to run dig command against all grid members

New Member
Posts: 4
7311     0

@Clark wrote:

Seems that lately I've had to do some troubleshooting with discrepancies in DNS records across grid members.  I got tired of manually typing the dig command for each grid member.  I created a simple BASH shell script that runs the same query across all the grid members.  Works for forward and reverse lookups, IPv4 and IPv6 lookups.  You have to define your grid members inside the script.  Hopefully they don't change much.  Thought someone else might find this useful xender discord omegle .

 

#!/bin/bash

# This script will run a dig command against your grid members
# so you can easily compare results between them.  You can specify
# dig options for forward and reverse lookups as well as IPv4 and
# IPv6 lookups.  Actually, you can use this to compare between any
# DNS servers, not just Infoblox appliances.  Added the time function
# in order to get the actual response time to the client.

# Define your Infoblox grid members here
# Data format is GRID_MEMBER_DISPLAY_NAME and IP_ADDRESS separated with a colon
# Each data pair is separated with a space
INTERFACE="ATL:10.11.12.21 BOS:10.11.12.18 DAL:10.11.12.7 DEN:10.11.12.114 SED:10.11.12.39 PORT:10.11.12.72 "


# Define regular expressions to validate IPv4 and IPv6 address format
IPv4_REGEX='^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'
IPv6_REGEX='^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$'

echo
echo
echo
echo
echo

echo -n "Enter the name or IP address of the host to query:  "
read QUERY

# Assume QUERY string is not an IP address until verified as such
# Old options were too brief
# OPTIONS="+noall +comments +question +answer +tries=1"
# Set forward query options here
OPTIONS="+tries=1"

# See if QUERY string is IPv4
# Set query options here
if [[ $QUERY =~ $IPv4_REGEX ]]; then
   # QUERY is a valid IPv4 address
   # Use the -x option in the dig command
   OPTIONS="+tries=1 -x"
fi

# See if QUERY string is IPv6
# Set query options here
if [[ $QUERY =~ $IPv6_REGEX ]]; then
   # QUERY is a valid IPv6 address
   # Use the -x option in the dig command
   OPTIONS="+tries=1 -x"
fi

echo
echo
echo
echo
echo

# Loop through all the grid members and run the dig command
for DATA in $INTERFACE; do
   NAME=`echo $DATA | cut -d":" -f1`
   IP=`echo $DATA | cut -d":" -f2`
   echo "*****************************************"
   echo "* RESULTS FOR INFOBLOX APPLIANCE AT $NAME"
   echo "*****************************************"
   echo "Response time:"
   echo -n "----------------"
   RESULT=`time dig $OPTIONS $QUERY @$IP`
   echo
   echo "$RESULT"
   echo
   echo
   echo
   echo
   echo
done

exit

The screen is Splitted to and you only type command once and excuted on all Memebers 

Re: Script to run dig command against all grid members

New Member
Posts: 1
7311     0

Thanks for the solution it is working for me.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You