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.

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

    Joined:
    Mar 18, 2010
    Messages:
    30
    Likes Received:
    1
    Trophy Points:
    8
    Hi,

    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

    Thanks
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hello,

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

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

    Code:
    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 domain.com entries, then input an domain.com entry for a nameserver called ns3.domain.com into the /var/named/domain.com.db files where domain.com 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:

    Code:
    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 ns3.domain.com 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:

    http://forums.cpanel.net/f5/how-incremental-serial-number-dns-zone-211732.html#post873142

    Thanks!
     
Loading...

Share This Page