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!

DNS Zone Reset ALL

Discussion in 'Bind/DNS/Nameserver' started by romacities, Aug 26, 2011.

  1. romacities

    romacities Member

    Joined:
    Sep 10, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    51
    Location:
    Denver, CO
    cPanel Access Level:
    Root Administrator
    Under:
    Main >> DNS Functions >> Reset a DNS Zone
    There's a list of domains which I can click and reset to default current DNS settings.

    Is there an automated way to reset all domains at once?

    thanks.
     
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,423
    Likes Received:
    1,957
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello :)

    There are no tools or scripts included with cPanel that will automatically reset all DNS Zones on a server. I encourage you to open a feature request for such an option via:

    Feature Requests for cPanel and WHM

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,608
    Likes Received:
    32
    Trophy Points:
    238
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    This could be done with two commands in command line. One to kill the DNS zones and one to add the DNS zones. I'm only selecting the domains in /etc/trueuserdomains, which are the main domains. The issue here is going to be that subdomains will be yanked when doing this. You might change to grabbing the list from /etc/localdomains instead without the cut portion. Before doing this, a backup must be made of /var/named and /etc/named.conf:

    Code:
    cp -R /var/named /var/named.bak110826
    cp -R /etc/named.conf /etc/named.conf.bak110826
    The commands would then be to remove and readd the zones:

    Code:
    for i in `cat /etc/trueuserdomains | cut -d: -f1` ;do /scripts/killdns $i ;done
    for i in `cat /etc/trueuserdomains | cut -d: -f1` ;do /scripts/add_dns --domain=$i ;done
    I would highly suggest first running "/scripts/killdns domain.com" for one account, then "/scripts/add_dns --domain=domain.com" for that same account to see the results to ensure they are what you want before proceeding.

    Please note that you could load the list from a precompiled list of domains instead also, then use `cat /root/domainlist` instead of reading from /etc/trueuserdomains. This way you can control what domains are being touched.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. lukapaunovic

    lukapaunovic Active Member

    Joined:
    Jul 29, 2012
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Užice, Serbia
    cPanel Access Level:
    Root Administrator
    I urge admins/moderators to merge my reply to this thread: DNS Zone Reset ALL


    Since solution @cPanelTristan posted doesn't work anymore I found a working one. Because add_dns and adddns script produces this:

    Code:
    /scripts/adddns --overwrite --ip 192.168.1.1 --domain mydomain.com --owner username

    Even with all correctly specified arguments. Probably because of absolute use of the API.

    So I finally succeeded using command line API like specified here

    First, of course, make backup and remove your zones like @cPanelTristan suggested.

    Then replace 192.168.1.1 with your main shared IP and run this:

    Code:
    data=$(cat /etc/trueuserdomains | tr -d ' ')
    ip="192.168.1.1"
    for i in $data ;do
    domain=$(echo $i | awk -F':' '{print $1}')
    owner=$(echo $i | awk -F':' '{print $2}')
    
    echo ;
    echo Creating zone $domain on $owner;
    whmapi1 adddns domain=$domain trueowner=$owner ip=$ip
    echo ;
    done
     
  5. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,423
    Likes Received:
    1,957
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @lukapaunovic,

    I've merged your post with this thread.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Giuseppe

    Giuseppe Registered

    Joined:
    Apr 23, 2016
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Italy
    cPanel Access Level:
    Root Administrator
    Hello,

    I suggest this command:

    Code:
    for i in $(cat /etc/trueuserdomains | cut -d: -f1); do whmapi1 resetzone domain=$i; done
     
Loading...

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