Skip to main content

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

Comments

4 comments

  • cPanelMichael
    Hello @Kent Brockman, Do you mind opening a
    0
  • Kent Brockman
    Hello @Kent Brockman, Do you mind opening a
    0
  • Kent Brockman
    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
    0
  • cPanelMichael
    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: [QUOTE] 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.
    [QUOTE] 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.
    [QUOTE] 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.
    0

Please sign in to leave a comment.