Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Member
    Join Date
    Sep 2003
    Posts
    23

    Default Possible to edit multiple DNS zones

    I'm about to move servers and I want to lower the TTL value on all the domains in my WHM - there are about 100.

    Is there any way of modifying all these at once, or am I going to have to edit each DNS zone manually?

    Thanks

    Andrew

  2. #2
    Member PWSowner's Avatar
    Join Date
    Nov 2001
    Location
    ON, Canada
    Posts
    2,994

    Default

    When I need to do things like that, I just download the files, open them in a good text editor like cutehtml or notetabpro, and use search/replace, then upload the new files. Takes a total of about 5 minutes for 100 files.

    If you prefer from shell, see this thread.
    Mike
    WHM and cPanel Scripts (join our "Scripts Club")
    D/A Photography

  3. #3
    Member
    Join Date
    Sep 2003
    Posts
    23

    Default

    Originally posted by squirrel
    When I need to do things like that, I just download the files, open them in a good text editor like cutehtml or notetabpro, and use search/replace, then upload the new files. Takes a total of about 5 minutes for 100 files.

    If you prefer from shell, see this thread.
    Thanks.

    Which files do I need to download though - all the named.db files?

  4. #4
    Member PWSowner's Avatar
    Join Date
    Nov 2001
    Location
    ON, Canada
    Posts
    2,994

    Default

    Yes
    Should be /var/named/[domain].db

    Just make sure you upload and download in ascii not binary.
    Mike
    WHM and cPanel Scripts (join our "Scripts Club")
    D/A Photography

  5. #5
    Member bamasbest's Avatar
    Join Date
    Jan 2004
    Posts
    531

    Default

    From shell:

    (first, backup all of your files

    then:

    find /var/named -type f -exec \
    sh -c 'gawk "$0" "$1" > "$1.tmp"; mv "$1.tmp" "$1"' \
    '{gsub("oldvalue","newvalue"); print $0}' '{}' \;


    Just replace oldvalue and newvalue with the appropriate values.

    So, if you wanted to change "expire" from 3600000 to 600 .....

    find /var/named -type f -exec \
    sh -c 'gawk "$0" "$1" > "$1.tmp"; mv "$1.tmp" "$1"' \
    '{gsub("3600000","600"); print $0}' '{}' \;

  6. #6
    Member
    Join Date
    Sep 2003
    Posts
    23

    Default

    Thanks to you both.

  7. #7
    Member
    Join Date
    Oct 2004
    Posts
    65

    Thumbs up You saved me hours of work. Sweet

    Quote Originally Posted by bamasbest
    From shell:

    (first, backup all of your files

    then:

    find /var/named -type f -exec \
    sh -c 'gawk "$0" "$1" > "$1.tmp"; mv "$1.tmp" "$1"' \
    '{gsub("oldvalue","newvalue"); print $0}' '{}' \;


    Just replace oldvalue and newvalue with the appropriate values.

    So, if you wanted to change "expire" from 3600000 to 600 .....

    find /var/named -type f -exec \
    sh -c 'gawk "$0" "$1" > "$1.tmp"; mv "$1.tmp" "$1"' \
    '{gsub("3600000","600"); print $0}' '{}' \;

    YOU ARE AWESOME!!

  8. #8
    Member
    Join Date
    Mar 2004
    Posts
    710

    Default

    how about:

    replace '36000' '6000' -- *.db

    Lots easier and command line. No script needed.
    Lloyd F Tennison

  9. #9
    Super Moderator This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,495

    Default

    Bear in mind that if you touch a zone file you should always increment the SERIAL number too.
    Jonathan Michaelson

    Need your cPanel servers secured and tuned?
    cPanel Server Configuration, Security, Recovery and Antivirus/AntiSpam Services
    Developers of the most effective (and free) Firewall & Security Solution for cPanel Servers - csf
    http://www.configserver.com

Similar Threads & Tags
Similar threads

  1. Dnsonly edit DNS zones
    By 1ONE in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 06-08-2010, 11:23 AM
  2. Cannot edit DNS Zones
    By hightekhosting in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 10-16-2007, 12:34 PM
  3. Mass Edit DNS Zones
    By maxihost2 in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 09-13-2005, 09:25 AM
  4. Edit DNS zones problem!
    By gemby in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 06-11-2003, 03:23 AM
  5. Edit a DNS Zones shows no zones
    By bambenek in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 02-01-2002, 09:14 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube