Delete unneeded DNS entries after taking a server off of a DNS Cluster?

Kent Brockman

Well-Known Member
PartnerNOC
Jan 20, 2008
1,354
79
178
Buenos Aires, Argentina
cPanel Access Level
Root Administrator
Hello guys. I noticed that when you detach a server from a DNS Cluster, when you go to Edit DNS screen in WHM it will still show some residual domains of the cluster, and the same happen with the other cluster members, that will show domains from the server you just took off.

Is this a bug?? Besides that...
  • In the cluster: How can I remove domains that are not part of the cluster anymore?
  • In the detached server: How can I remove domains that are part of the old cluster?

Thanks!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
Hello @Kent Brockman,

Do you mind opening a defect report so we can take a closer look to confirm any defects (or unintended consequences) associated with the removal of a name server from an existing DNS cluster? You can post the ticket number here and we'll link this thread to it.

Thank you.
 

Kent Brockman

Well-Known Member
PartnerNOC
Jan 20, 2008
1,354
79
178
Buenos Aires, Argentina
cPanel Access Level
Root Administrator
Hello @Kent Brockman,

Do you mind opening a defect report so we can take a closer look to confirm any defects (or unintended consequences) associated with the removal of a name server from an existing DNS cluster? You can post the ticket number here and we'll link this thread to it.

Thank you.
Done! Ticket #12225103
 
  • Like
Reactions: cPanelMichael

Kent Brockman

Well-Known Member
PartnerNOC
Jan 20, 2008
1,354
79
178
Buenos Aires, Argentina
cPanel Access Level
Root Administrator
Update: the reply was unbelievably unsatisfactory :)

"The described behavior is not considered a bug, but is just currently the expected behavior when removing a server from a dns cluster."

I asked this in the ticket and repeat it here: how come is that possible?

How come leaving external DNS entries on place is the expected behaviour after detaching a server from a cluster? Why would this be the expected behaviour? Cause if I detach a server from a cluster, it's because I no longer need to have those domains in handy. Also, the DNS entries from domains in detached servers should as well be deleted from the machines in the cluster! Why would it not happen like this?

Also, the described methods to deleted unrelated domains' entries from the detached server, are impractical and dangerous.

I bet that if you can list the current domains, being those individual ones, parked, subdomains or addons, you should be able to make a list and compare it with the list of dns entries in bind directories in order to delete those which don't belong to the server. Is this possible? I'm sure it is, but I'm not that skilled programmer to code a perfect bash script to perform this. In change, your devs should be. Can you guys write a script doing this and deleting unrelated DNS entries?

Thanks
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
Hello @Kent Brockman,

Here are some quotes from one of our Technical Analysts on the support ticket in response to the concern noted in your previous response:

Because having zones get automatically deleted when removing a server from a cluster could be dangerous, and it could lead to sites going down and becoming inaccessible.

There are also many legitimate instances where someone may want to keep the zones on the server in their current state while removing the server from the cluster. I actually had to assist someone with this earlier today while they were migrating from one WHM server to another.
Normally, cPanel does not provide bash scripting services, as this is best handled by a qualified systems administrator. However, I did do some testing of this and I did come up with a working one-liner. I would be happy to provide you with this as a courtesy.

=====================
find /var/named/ -maxdepth 1 -type f -name '*.db' -print | sed -r 's#(^/var/named/|.db$)##g' | while read domain; do owner=$(/scripts/whoowns ${domain}); [ -z ${owner} ] && echo ${domain} >> /root/unowned_domains ; unset domain; unset owner; done
=====================

Try running this on your server, and then review the contents of the file /root/unowned_domains -- it should contain a list of the domains not considered owned by any users.

Some of these domains could potentially be ones you want to keep, such as a zone for your hostname. I would suggest reviewing it carefully before you attempt to delete them all.
I would iterate over the file and delete them with /scripts/killdns:

For example:

================
# always make a backup first -- this backs up your named zones and config

# mkdir -pv /root/cptechs/12225103
mkdir: created directory `/root/cptechs/12225103'
# tar -czf /root/cptechs/12225103/named_stuff.$(date +%s).tar.gz /etc/named* /var/named
tar: Removing leading `/' from member names
# cat /root/unowned_domains | while read domain; do /scripts/killdns ${domain:?} ; done
example.com => deleted from cent6.
================
Additionally, here's the link to the feature request that's open to include this functionality in cPanel & WHM:

Add a feature to remove residual DNS entries from a server

Thank you.