Skip to main content

Change TTL in all domains

Comments

14 comments

  • nixuser
    Hmm.. seems like they removed it.
    0
  • cPanelLauren
    This hasn't changed in some time, just to double check I created a 76 server and checked and there's no option to select all there either. There is also a feature request for this which can be found here: Bulk change/modify DNS Zone files
    0
  • jmginer
    @cPanelLauren Here I have a server 11.68 and I can select the first record, press the key shift of the keyboard and when I select the last record, all the records of the list are selected. In the new versions, with the checkbox it is no longer possible. Imagine how frustrating it is to have to edit the TTL of 600 domains by hand, one by one... Do you understand that this is impossible? Now imagine that you have the TTL of all your domains defined at 300 seconds and that you are receiving DNS attacks... An option to reduce the requests is to increase the TTL, but there are 600 domains... do you understand the problem? I hope you understand that we need to get back this feature you removed... I guess by mistake. Thanks! 59971
    0
  • cPanelLauren
    I understand the frustration and can see the merit in being able to select multiple. I'd again suggest the feature request if you must do this through the UI but there are most certainly simple ways to achieve this using the CLI. For example you could potentially use replace to do this for all zone records in /var/named. I took a couple of minutes to get this together for you: Make backups of your zone files: cp -rpf /var/named /var/named.backup
    use replace to change the TTL: replace "300" "14400" -- /var/named/*.db
    update the serial: grep "Serial Number" /var/named/*.db | sed "s/://g" | cut -d/ -f4 | awk {'system("replace "$2" "strftime("%Y%m%d")"00 -- /var/named/"$1)'}
    0
  • verdon
    That's handy. You would then also need to re-start bind I imagine?
    0
  • cPanelLauren
    You certainly could though it's not mandatory.
    0
  • verdon
    You certainly could though it's not mandatory.

    Good to know!
    0
  • jmginer
    I'm sorry, but your proposal is not acceptable. That command will break any DNS record that includes the string "300", for example a domain that is as300.net will be renamed to as14400.net And that is assuming that all domains have the TTL at 300, if each domain has a different TTL... I can't believe it... You eliminate a functionality and to put it back into operation you ask me to vote for a feature... And all this, after raising the price of licenses ... This is totally unacceptable.
    0
  • LucasRolff
    @jmginer, You can use /usr/local/cpanel/bin/set_zone_ttl to bulk update TTL for either a list of domains, a user or all domains in your DNS cluster. If you want to update TTL for all users on a given server, you can do something like: for user in $(ls /var/cpanel/users); do /usr/local/cpanel/bin/set_zone_ttl --user $user --newttl 60; done
    You can pass --force if you don't want to confirm for every account :) Edit: I'm more curious why you still have a v68 box around that has a root exploitable exim installation :)
    0
  • jmginer
    Thank you very much @LucasRolff !!!! Obviously I don't have any v68 server in production, but I have a snapshot of a pre-configured template and I was able to restore it just to provide the screenshot of my second response in this thread.
    0
  • David Colter
    Thank you @LucasRolff Your solution worked. David
    0
  • jmginer
    for user in $(ls /var/cpanel/users); do /usr/local/cpanel/bin/set_zone_ttl --user $user --newttl 300 --force; done
    0
  • Bidi
    Hello guys, I read somewhere is good to set ttl to 300 if you whant to migrate websites/accounts to a new server, is this true ? And is there a option to set ttl to 300 for the new accounts migrated on the new server till we move the ips two ? For me i whant to migrate 300accounts to a new server but all the websites to be on the same ip like in older one Chears
    0
  • cPRex Jurassic Moderator
    I usually go with 300, as that is 5 minutes, and set that up a few days before I plan to do a migration. That way the lowered TTL has time to propagate before I make any changes. To change the default value, you'd want to go to the very first option in WHM, Basic WebHost Manager setup, and change the value next to this text to 300: "This value defines the caching time for host name lookups for domains hosted on this server. When a caching nameserver queries the authoritative nameserver for a resource record, this value defines the number of seconds before the record will expire. Shorter TTL values can cause heavier loads on the nameserver, but can be useful for zones that contain frequently changing records. The range of values in seconds as defined by RFC 2181 is 0 to 2147483647." That will change the value for any newly-created zones.
    0

Please sign in to leave a comment.