File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
# script to dig subdomain `A` records
3
+ # shellcheck disable=SC2027
4
+ # shellcheck disable=SC2086
3
5
4
6
function get_a_records(){
7
+ if [[ -n " $2 " ]]; then
8
+ response=" $( dig " $2 .$1 " | grep -i -A1 " answer section" | tail -n 1) "
9
+ destination=" $( echo " $response " | awk ' { print $5 }' ) "
10
+ record_type=" $( echo " $response " | awk ' { print $4 }' ) "
11
+ echo " The subdomain " $2 " is a " $record_type " record and points to " $destination " "
5
12
13
+ else
14
+ subdomains=(www lb-01 web-01 web-01)
15
+ for sub_d in " ${subdomains[@]} " ; do
16
+ response=" $( dig " $sub_d .$1 " | grep -i -A1 " answer section" | tail -n 1) "
17
+ destination=" $( echo " " $response " " | awk ' { print $5 }' ) "
18
+ record_type=" $( echo " " " $response " " " | awk ' { print $4 }' ) "
19
+ echo " The subdomain " " $sub_d " " is a " " $record_type " " record and points to " " $destination " " "
20
+
21
+ done
22
+ fi
23
+
6
24
}
7
- get_a_records;
25
+ get_a_records " $1 " " $2 " ;
You can’t perform that action at this time.
0 commit comments