Difference between revisions of "Denied DNS Requests"

From James Dooley's Wiki
Jump to: navigation, search
(Created page with "==Overview== Find denied queries against DNS, good for finding sites that are no longer hosted or do not have valid DNS records. ==Script== <code>[bash,n] cat /var/log/messages ...")
 
(Script)
Line 2: Line 2:
 
Find denied queries against DNS, good for finding sites that are no longer hosted or do not have valid DNS records.
 
Find denied queries against DNS, good for finding sites that are no longer hosted or do not have valid DNS records.
  
==Script==
+
==Get all denied domains==
 
<code>[bash,n]
 
<code>[bash,n]
 
cat /var/log/messages | grep named | grep denied | cut -d "'" -f2 | cut -d "/" -f1 | sort | uniq -ci | sort -nr > /root/denied_dns.txt
 
cat /var/log/messages | grep named | grep denied | cut -d "'" -f2 | cut -d "/" -f1 | sort | uniq -ci | sort -nr > /root/denied_dns.txt
 +
</code>
 +
 +
==Create dummy zone for top 10 domains==
 +
 +
This will create a zone file using cPanels add_dns script and point it to 127.0.0.1 for the top 10 domains.
 +
 +
<code>[bash,n]
 +
for domain in $(head /root/denied_dns.txt | awk '{print $2}' | sed 's/www\.//'); do echo "Adding $domain"; /scripts/add_dns --domain $domain --ip 127.0.0.1; done
 
</code>
 
</code>

Revision as of 15:14, 12 January 2012

Overview

Find denied queries against DNS, good for finding sites that are no longer hosted or do not have valid DNS records.

Get all denied domains

[bash,n] cat /var/log/messages | grep named | grep denied | cut -d "'" -f2 | cut -d "/" -f1 | sort | uniq -ci | sort -nr > /root/denied_dns.txt

Create dummy zone for top 10 domains

This will create a zone file using cPanels add_dns script and point it to 127.0.0.1 for the top 10 domains.

[bash,n] for domain in $(head /root/denied_dns.txt | awk '{print $2}' | sed 's/www\.//'); do echo "Adding $domain"; /scripts/add_dns --domain $domain --ip 127.0.0.1; done