I need to record all outgoing A
records on a RedHat PC. I tried using tcpdump
:
tcpdumpdns=OUTPUT-FILENAME-HERE
nohup tcpdump -K dst port 53 -w $tcpdumpdns > /dev/null 2>&1 &
It makes an output file like:
19:26:12.185392 IP 172.16.0.6.57977 > google-public-dns-a.google.com.domain: 51198+ A? yahoo.com. (27)
So I need to process that to get the yahoo.com
:
echo $tcpdumpdns | awk '/ A\? / {u = NF - 1; print $u}' | sed 's/^www.//g; s/.$//g' | sort -u
Is there any better solution to gather all the outgoing A
record requests?
p.s.: collecting DNS A records is only needed to have an up-to-date list of websites that are reachable via HTTPS. So I can generate xml files for HTTPSEverywhere Firefox Add-on. So this is just a part of a script.