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.

Changing the NS records for multiple zones

Discussion in 'General Discussion' started by movielad, Jun 30, 2009.

  1. movielad

    movielad Well-Known Member
    PartnerNOC

    Joined:
    May 14, 2003
    Messages:
    107
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    DataCenter Provider
    Hello,

    I have 323 DNS zones on a cPanel server whose NS records I need to change within the zones themselves. Is there a quick 'n' dirty way of applying multiple changes across DNS zones?

    Thanks,

    Martyn
     
  2. PlatinumServerM

    PlatinumServerM Well-Known Member
    PartnerNOC

    Joined:
    Jul 10, 2005
    Messages:
    397
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    New Jersey, USA
    cPanel Access Level:
    Root Administrator
    If you want to do a from -> to change then you can use the replace command

    replace fromxxxx toxxxx -- /var/named/*

    Make a backup first before doing that
    tar cf /var/namedbackup.tar /var/named
     
  3. movielad

    movielad Well-Known Member
    PartnerNOC

    Joined:
    May 14, 2003
    Messages:
    107
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    DataCenter Provider
    Thanks. I had quite forgotten about /var/named/*.
     
  4. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    Just a little bit cleaner run of the same command written for fewer unintended
    side effects than what PlatinumServerM had in good faith posted above ....

    Code:
    # replace '(old string)' '(new string)' -- /var/named/*.db
    You can run this putting whatever you want for (old string) and (new string)
    respectively and all instances of those strings will be updated in your DNS
    zone files on your server.

    Don't forget to update the serial number on your zone files and restart
    your "named" service to make the changes effective:
    Code:
    # sed -i 's/200[0-9]\{7\}/2009063010/g' /var/named/*.db
    # service named restart
    # service named status
    
    (Incidentally the serial number in the example above is one you might use for updating all the
    zone files to a valid serial number for the date this post was made and runs in the
    format of "yyyymmddee" where y= year, m = month, d = day, and e = edit number for day)


    .
     
    #4 Spiral, Jul 1, 2009
    Last edited: Jul 1, 2009
Loading...

Share This Page