Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Member
    Join Date
    Sep 2006
    Posts
    73

    Default DNS cleanup

    Accidently synced all zones from the nameservers to a shared server. Is there a way to clean up the zones not hosted locally on the shared server ?
    Tried cleandns but I think it will remove the zone entry only if the db file is not present.

  2. #2
    cPanel Partner NOC cPanel Partner NOC Badge
    Join Date
    Jul 2005
    Location
    New Jersey, USA
    Posts
    397

    Default

    You can write a script that compares each zone in /var/named/ to the domains in /etc/userdomains

    For any that don't exist, it can remove the dns zone.

  3. #3
    Member sneader's Avatar
    Join Date
    Aug 2003
    Location
    La Crosse, WI
    Posts
    932
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Anyone happen to have such a script? I could use this also.

    - Scott

  4. #4
    Member sneader's Avatar
    Join Date
    Aug 2003
    Location
    La Crosse, WI
    Posts
    932
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    I opened a ticket regarding a similar issue, and asked about a script. cPanel was able to clean things up for me, and the tech said he'd post a script and the process in the near future, in case others could benefit from this.

    - Scott
    Last edited by sneader; 09-19-2009 at 03:51 PM.

  5. #5
    BANNED
    Join Date
    Jun 2005
    Location
    Wild Wild West
    Posts
    2,025

    Lightbulb

    I have several specialized scripts to do these sort of tasks but to be perfectly honest, you would be much better off rebuilding your DNS zones from scratch unless you have a lot of custom edits you are trying to protect.

    I'd just wipe (or preferably move) the /var/name/*.db files from their current
    location and then renamed your /etc/named.conf file and then you can issue a rebuild of the "named" server config file and DNS zones and that should get you back up and running again in about 15 seconds.

  6. #6
    Member
    Join Date
    Jun 2003
    Location
    matrix
    Posts
    60

    Default

    does anyone have this script, which compare /var/named/domain.com.db zone in /etc/localdomains and then remove it / move it to another folder ?

  7. #7
    BANNED
    Join Date
    Jun 2005
    Location
    Wild Wild West
    Posts
    2,025

    Lightbulb

    Quote Originally Posted by mahinder View Post
    does anyone have this script, which compare /var/named/domain.com.db zone in /etc/localdomains and then remove it / move it to another folder ?
    If your intent is cleaning up you DNS, you are going about it the wrong way!

    However, since you asked:
    Code:
    #!/bin/bash
    IFS="$"
    
    # Put the folder you want to move the zones to below:
    TARGET="/var/localzones"
    
    cd /var/named
    
    if [ ! -d ${TARGET} ]; then
       mkdir ${TARGET}
    fi
    
    ### If you want to move out remotedomains, change next line:
    
    cat /etc/localdomains | while read CPDOMAIN; do 
       if [ -f /var/named/${CPDOMAIN}.db ]; then
          mv /var/named/${CPDOMAIN}.db ${TARGET}/${CPDOMAIN}.db
       fi
    done

  8. #8
    Member
    Join Date
    Jun 2003
    Location
    matrix
    Posts
    60

    Default

    Quote Originally Posted by Spiral View Post
    If your intent is cleaning up you DNS, you are going about it the wrong way!
    thank you for script. Can you please tell me what would be the correct way?.

    We have 6 servers in cluster and number of zones have increased to 7000+, all are setup to sync with each other and now its taking long time for bind/named to load all zones at startup. named.conf has increased to 50,000 lines.

    I have changed settings on all web servers to syn only with dns server and dns server do not sync zones with web servers. Now, We want to remove unnecessary zones from web servers but want to keep all zones only on dns server where they are backed up every few hours.

    Can you please suggest any workaround for it?

  9. #9
    BANNED
    Join Date
    Jun 2005
    Location
    Wild Wild West
    Posts
    2,025

    Default

    I could probably tell you better if I saw your current DNS configuration.

    I do have scripts that can sort out zones back to their original servers but sounds like your DNS might not be setup the best it could be setup.

Similar Threads & Tags
Similar threads

  1. I performed a DNS cleanup by mistake!!!
    By yoursalways in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 01-13-2007, 02:32 PM
  2. WHM DNS Cleanup option question
    By zurca in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 10-06-2006, 05:59 PM
  3. Dns Cleanup
    By picoleto in forum New User Questions
    Replies: 0
    Last Post: 08-08-2006, 07:47 PM
  4. DNS Cleanup
    By tbtucholka in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 01-30-2006, 03:45 PM
  5. What happens here? Perform a DNS Cleanup
    By pingo in forum cPanel and WHM Discussions
    Replies: 5
    Last Post: 03-26-2004, 07:40 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube