From a498418b06e0e92ebf0065450f1969676b96cd1f Mon Sep 17 00:00:00 2001 From: bilogic <946010+bilogic@users.noreply.github.com> Date: Fri, 5 Jan 2024 16:15:42 +0800 Subject: [PATCH] configurable TTL --- management/dns_update.py | 6 +++--- setup/start.sh | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/management/dns_update.py b/management/dns_update.py index 9a768ea8..4bdc732f 100755 --- a/management/dns_update.py +++ b/management/dns_update.py @@ -501,19 +501,19 @@ def write_nsd_zone(domain, zonefile, records, env, force): zone = """ $ORIGIN {domain}. -$TTL 86400 ; default time to live +$TTL {ttl} ; default time to live @ IN SOA ns1.{primary_domain}. hostmaster.{primary_domain}. ( __SERIAL__ ; serial number 7200 ; Refresh (secondary nameserver update interval) 3600 ; Retry (when refresh fails, how often to try again, should be lower than the refresh) 1209600 ; Expire (when refresh fails, how long secondary nameserver will keep records around anyway) - 86400 ; Negative TTL (how long negative responses are cached) + {ttl} ; Negative TTL (how long negative responses are cached) ) """ # Replace replacement strings. - zone = zone.format(domain=domain, primary_domain=env["PRIMARY_HOSTNAME"]) + zone = zone.format(domain=domain, primary_domain=env["PRIMARY_HOSTNAME"], ttl=env["TTL"]) # Add records. for subdomain, querytype, value, explanation in records: diff --git a/setup/start.sh b/setup/start.sh index 459dc7e3..317d5895 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -104,6 +104,7 @@ PUBLIC_IPV6=$PUBLIC_IPV6 PRIVATE_IP=$PRIVATE_IP PRIVATE_IPV6=$PRIVATE_IPV6 MTA_STS_MODE=${DEFAULT_MTA_STS_MODE:-enforce} +TTL=${DEFAULT_TTL:-86400} EOF # Start service configuration.