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.

Edit DNS zone / nameserver for all Accounts in one go !

Discussion in 'Bind / DNS / Nameserver Issues' started by kasra, May 31, 2007.

  1. kasra

    kasra Member

    Joined:
    Dec 10, 2004
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Its my Cpanel/WHM VPS I am talking about,

    I had to change my hostnames AND both my Nameservers
    after change , all accounts DNS zone are still showing old data ( old ns1 and ns2 )
    Is there any way to change nameservers for all DNS zones in one go ?

    Tnx in advance

    Kasra !
     
    #1 kasra, May 31, 2007
    Last edited: May 31, 2007
  2. kasra

    kasra Member

    Joined:
    Dec 10, 2004
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    No one's really have ever done it ?:confused:
     
  3. eNetHosts

    eNetHosts Well-Known Member

    Joined:
    Apr 21, 2007
    Messages:
    195
    Likes Received:
    0
    Trophy Points:
    16
    Make sure you edit both the name servers option and edit the DNS records.
     
  4. kasra

    kasra Member

    Joined:
    Dec 10, 2004
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    well ,
    thanks for ur reply.. I know what to do in order to change nameservers of this server ,
    my problem is that I want to do ALL ACCOUNTS in one act !

    doing 100 acoutns dns zone one by one is not logical !
     
  5. eNetHosts

    eNetHosts Well-Known Member

    Joined:
    Apr 21, 2007
    Messages:
    195
    Likes Received:
    0
    Trophy Points:
    16
    But people normally wouldn't need to change their name servers.

    There's two options. You can keep the existing accounts on the current name servers and set up two new name servers for new accounts to use having these in your WHM alongside the originals.

    or

    You can change each accounts name server manually. Bearing in mind that also the 100 accounts must have this information registrar end.

    So if your current name servers are ns1.defs.com 1.1.1.1 and ns2.defs.com 1.1.1.2

    and you are changing them to ns1.defsa.com and ns2.defsa with:

    a) Different IPs or
    b) Same IPs

    Either way the accounts at registrar end have to have this information updated and then it needs to propagate throughout DNS servers.
     
  6. jayh38

    jayh38 Well-Known Member

    Joined:
    Mar 3, 2006
    Messages:
    1,215
    Likes Received:
    0
    Trophy Points:
    36
    Use the find command or sed as the example I show here will work fine.

    for file in ls /var/named/*/; do
    sed -e 's/ns1.oldns.com./ns1.newns.com./g' "$file" > tmp_file
    mv tmp_file "$file"
    done


    This will search the string of your present(old) ns and replace it with the new. Do backup your /var/named or simply copy the directory and run this on the copy and check the configuration. So again, DO NOT run this on your original unless you have a backup of the directory.

    enjoy.
     
  7. eNetHosts

    eNetHosts Well-Known Member

    Joined:
    Apr 21, 2007
    Messages:
    195
    Likes Received:
    0
    Trophy Points:
    16
    That method won't eliminate the current DNS issue you have though.
     
  8. jayh38

    jayh38 Well-Known Member

    Joined:
    Mar 3, 2006
    Messages:
    1,215
    Likes Received:
    0
    Trophy Points:
    36
    This method will change the records in question of multiple files which is what he is asking to accomplish. I have given a solution to a question that was asked without being presumptuous. Regardless, this bit of information could be applied to numerous situations.
     
  9. kasra

    kasra Member

    Joined:
    Dec 10, 2004
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Hey Guys,
    thanks alot to all,
    tha't find command sounds good ,
    Will report back ;)

    Cheers
    Kasra
     
  10. jasgot

    jasgot Well-Known Member

    Joined:
    Mar 2, 2004
    Messages:
    55
    Likes Received:
    1
    Trophy Points:
    6
    Dores NAMED need to be restarted after this change?
     
  11. mtindor

    mtindor Well-Known Member

    Joined:
    Sep 14, 2004
    Messages:
    1,281
    Likes Received:
    37
    Trophy Points:
    48
    Location:
    inside a catfish
    cPanel Access Level:
    Root Administrator
    It sure does - at lease an 'rndc reload'

    If you edit named.conf, 'rndc reconfig' or (on a redhat like system, 'service named reconfig') will reload the configuration.

    If you edit one of the zone files in /var/named, then you would do something like:

    rndc reload (reloads all zones, if their serial #s have changed)
    rndc reload <domain.name> - to reload an individual zone
    service named reload (reload all zones, on a redhat-like system)

    NOTE: Be SURE that you update the serial # on your zone files. If you run the script that Jay38 gave you, it will do exactly what you want - However, it will _not_ increment the serial number on the zone. That means that when you do a reload of the zone it will not reload.

    Even completely stopping named and restarting named won't necessarily reload the zone data if the serial #s are not updated. It will on the primary nameserver, but if you have any slave nameservers the zones on those will not automatically update unless the serial numbers in the primarys zone files are updated.

    So, bottom line, make sure you upload the serials in the zones just to be sure.

    Mike
     
  12. jasgot

    jasgot Well-Known Member

    Joined:
    Mar 2, 2004
    Messages:
    55
    Likes Received:
    1
    Trophy Points:
    6
    Is there a way to update the serials in that little script? If not, I have to go into each of them anyway... Ugh!
     
Loading...

Share This Page