Friday, September 13, 2019

.::: Sript multiple dig domain (DNS) using Script :::.

1. Sample host
[root@server-teguht teguht]# cat hostdomain.txt
www.example.com
example.com
a.example.com
aaa.example.com
aaaa.example.com
example.com
info.example.com
cname.example.com
examplealias.example.com
[root@server-teguht teguht]#

2. Create script multidig
[root@server-teguht teguht]# cat digmultiple.sh
#!/bin/bash
file=$1
#while IFS= read -r line;
for j in 'cat $1'
do
 i='echo $j | sed 's/\r//g''
  dig @1.1.1.1 $i
done
[root@server-teguht teguht]#

3. execure script to multidig

[root@server-teguht teguht]# sh digmultiple.sh hostdomain.txt | grep opcode > result.txt
[root@server-teguht teguht]#

4. check result multidig
[root@server-teguht teguht]# cat result.txt
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 31465
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 8338
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 21782
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 14564
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 17515
[root@server-teguht teguht]#

5. check total to compare hostdomain and result

[root@server-teguht teguht]# cat result.txt | grep -i nxdomain | wc -l
5
[root@server-teguht teguht]# cat result.txt | grep NXDOMAIN | wc -l
5
[root@server-teguht teguht]#

No comments:

Post a Comment

Popular Posts