The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Bulk DNS Zone Update

Discussion in 'Bind / DNS / Nameserver Issues' started by rezman, Jun 25, 2013.

  1. rezman

    rezman Well-Known Member

    Joined:
    Feb 3, 2011
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    Continued from: http://forums.cpanel.net/f5/bulk-edit-dns-zones-211731.html

    We're setting up new CP DNS only servers and I need to update all the DNS zones and remove the old DNS server and replace it with the new host address.

    Current:
    Code:
    ;; AUTHORITY SECTION:
    domain.com.             86400   IN      NS      [COLOR="#FF0000"]cpanel1.company.net[/COLOR].
    domain.com.             86400   IN      NS      cpanel2.company.net.
    New:
    Code:
    ;; AUTHORITY SECTION:
    domain.com.             86400   IN      NS      [COLOR="#FF0000"]cpdns1.company.net[/COLOR].
    domain.com.             86400   IN      NS      cpanel2.company.net.
    The command line "replace" would work perfect for this but is there a way to do it via WHM? I've already updated the nameservers under WHM > Basic cPanel & WHM Setup > Nameservers but it won't update the NS entry in all the zone files. I did the "replace" method on my personal domain, restarted named and did a dig @cpanel2.company.net mydomain.com and everything came back correct with the new AUTHORITY SECTION: DNS servers.
     
  2. stdout

    stdout Well-Known Member

    Joined:
    Apr 10, 2003
    Messages:
    189
    Likes Received:
    5
    Trophy Points:
    18
    Location:
    Nelspruit, Mpumalanga, South Africa
    cPanel Access Level:
    Root Administrator
    I don't know of any way to do it using WHM.
    Why don't you just use replace?

    1. Back up ALL DNS Zonefiles.
    Code:
    cp -rpf /var/named /var/named.backup
    2. Update the Nameserver's in ALL DNS Zonefiles:
    Code:
    replace "cpanel1.company.net" "cpdns1.company.net" -- /var/named/*.db
    3. Update the Serial/Timestamp in ALL DNS Zonefiles:
    Code:
    grep "serial, todays" /var/named/*.db | sed "s/://g" | cut -d/ -f4 | awk {'system("replace "$2" "strftime("%Y%m%d")"00 -- /var/named/"$1)'}
     
    greatwitenorth and urgido like this.
  3. robb3369

    robb3369 Well-Known Member

    Joined:
    Mar 1, 2008
    Messages:
    122
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Why don't you just add the new DNS server, sync it up and change the IP address of cpanel1.company.net in both your DNS and the registrar of your domain to the new IP address.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,762
    Likes Received:
    662
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    It's not possible to make this modification via Web Host Manager. You could use the "replace" command as mentioned, and then update the serials with the following commands:

    Code:
    # cp -a /var/named /var/named-backup 
    # find /var/named/*.db -mtime -1 -exec perl -pi -e 'if (/^\s+(\d{10})\s+;\s+serial/i) { my $i = $1+1; s/$1/$i/;}' '{}' \;
    Thank you.
     
  5. rezman

    rezman Well-Known Member

    Joined:
    Feb 3, 2011
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    @stdout & cPanelMichael

    Thank you all for the info. Using the 'replace' was my fallback option but I wanted to make sure there wasn't some hidden way within WHM first. Also I didn't know an easy way to update the serial numbers off hand. Thank you for these twp examples.


    @robb3369:

    That's an option for now and I will be doing that as a temporary solution but at some point we want to bring the cpanel1 server back online and use it as a full Cpanel server. Right now it is but only acting as a secondary DNS server. Need to bring it offline for now which is why I'm setting up DNS only servers so if this happens in the future I won't need to deal with updating domain name servers (again).
     
  6. WEBDOMAIN.com

    WEBDOMAIN.com Active Member

    Joined:
    Jun 29, 2007
    Messages:
    35
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Europe
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    Bumping an old thread.
    How to bulk add a third and fourth NS in the DNS records where they don't exists?
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,762
    Likes Received:
    662
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    You may find this thread helpful:

    Bulk DNS Insert

    Thank you.
     
  8. cglmicro

    cglmicro Member

    Joined:
    Oct 14, 2013
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    In my case, I also had to run this since many domains have different phrasing :
    Code:
    grep "Serial Number" /var/named/*.db | sed "s/://g" | cut -d/ -f4 | awk {'system("replace "$2" "strftime("%Y%m%d")"00 -- /var/named/"$1)'}
    
    Another question: my files contain the priority that need to be changed from 21 to 10. I don't want to run:
    Code:
    replace "21" "10" -- /var/named/*.db
    
    because it will change some things like IP 69.70.71.21 to 69.70.71.10.

    QUESTION #1: What would be the command to only change:
    Code:
    replace "{TAB}21{TAB}" "{TAB}10{TAB}" -- /var/named/*.db
    
    QUESTION #2: On my secondary NS that run under WHM_DNSONLY, should I force a full synchronisation, or should I wait for it to be done automaticaly?

    Thanks!
     
  9. cglmicro

    cglmicro Member

    Joined:
    Oct 14, 2013
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    I found that this do the job:
    Code:
    replace "\t21\t" "\t10\t" -- /var/named/*.db
    
    Just my question #2 to get an answer now.
     
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,762
    Likes Received:
    662
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    You can manually synchronize the zones after updating the serials.

    Thank you.
     
Loading...

Share This Page