Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

The easiest way to add a third NS record to 200 domains?

Discussion in 'General Discussion' started by vs-fam, Jul 18, 2011.

  1. vs-fam

    vs-fam Active Member

    Mar 18, 2010
    Likes Received:
    Trophy Points:

    I need to add a third NS record to about 200 zone files. I'm going nuts doing it one by one editing each zone file.

    Is there a way to do this in an easiest way ? Bulk ?

    The biggest issues are:
    • NS record changes from domain to domain as the record must include its specific domain
    • Serial numbers

  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst Staff Member

    Oct 2, 2010
    Likes Received:
    Trophy Points:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator

    If you need to add this to all domain zones, you could do the following where you are backing up named zones first:

    cd /var
    cp -R named named.bak110718
    Next, you would add the nameserver entries with this command:

    for x in `cat /etc/trueuserdomains | cut -d: -f1` ; do echo "$x. 86400 IN NS ns3.$x." >> /var/named/$x.db ; done
    This will cat /etc/trueuserdomains and pull out the entries, then input an entry for a nameserver called into the /var/named/ files where matches the domain name in each instance. If you wish to use something besides ns3 for the nameserver name, you'd replace the ns3 portion only. The rest of the command would not be replaced in any fashion.

    You likely also will need to add an A record for each of these as well, which could be done with this command:

    for x in `cat /etc/trueuserdomains | cut -d: -f1` ; do echo "ns3.$x. 14400 IN A IP#" >> /var/named/$x.db ; done
    This will input an A record entry for the IP# where IP# would need to be replaced by the IP number being used. Hopefully, all of these domains will be using the same IP for the assorted nameservers. If they are not, then it would be far more difficult to accomplish this task as a list of domains and IPs would have to be created, then a script used to pull the IP from that list.

    Finally, to update the SOA, you would likely want to use the advise in this post:

    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice