Identify orphaned DNS zones
How do I identify orphaned DNS zones.
Looks like /usr/local/cpanel/scripts/cleandns
will clean them all blindly, but I want to extract a list for review.
Advice anyone?
-
Hey there! If the server is part of a DNS cluster, you can use this command to look through the /etc/managedzones file on the machine and get such a list:
for domains in $(ls /var/named/*.db | cut -d '/' -f 4 | awk 'BEGIN{FS=OFS="."}{NF--; print}' ); do if ! (grep -q $domains /etc/managed_domains);
This is modified from our documentation here about cleaning up a bad cluster configuration:
Let me know if that works for your situation!
0 -
Sorry, not my programming/scripting language.
It acts as if I'm not complete or closing something, or mis-copy/pasted. So I'm trying to break it down.
This drops to the next command prompt as if not finished: ">"
This works fine and gives me a list of domains:
ls /var/named/*.db | cut -d '/' -f 4 | awk 'BEGIN{FS=OFS="."}{NF--; print}'
Is there supposed to be more after:
.... do if ! (grep -q $domains /etc/managed_domains);
0 -
I should add that I don't have a folder or file named /etc/managed_domains
0 -
Here is what I came up with, after using yours as a jump off point:
for domains in $(ls /var/named/*.db | cut -d '/' -f 4 | awk 'BEGIN{FS=OFS="."}{NF--; print}' ); do if ! (grep -q $domains /etc/userdomains ) then echo $domains;fi; done;
1 -
This is slightly cleaner alternative:
for domain in $(find /var/named/ -maxdepth 1 -type f -name "*.db" -exec basename \{} .db \;); do if ! grep -q "^$domain" /etc/userdomains; then echo "$domain"; fi; done;
It uses `find` to return the list with ".db" files and to strip the ".db" extention (no need for awk).
1 -
Yes, this alternative worked for me, thanks for it.
0 -
I'm glad you found a good solution!
0
Please sign in to leave a comment.
Comments
7 comments