[GH-ISSUE #118] A Record Ttl and NS Ttl #370

Open
opened 2026-03-13 14:47:51 +03:00 by kerem · 1 comment
Owner

Originally created by @pengyuu on GitHub (Mar 13, 2020).
Original GitHub issue: https://github.com/abh/geodns/issues/118

I try to set NS ttl like this:
test.example.com.json

{
    "serial":3,
    "ttl":600,
    "data":{
        "":{
            "ns":{
                "ns1.example.net.":null,
                "ns2.example.net.":null
            },
            "ttl":"300000"
        }
    }
}

but A record ttl:

$ dig  test.example.com

;test.example.com.		IN	A

;; ANSWER SECTION:
test.example.com.	300000	IN	A	192.168.0.1

$ dig ns test.example.com

;; QUESTION SECTION:
;test.example.com.		IN	NS

;; ANSWER SECTION:
test.example.com.	300000	IN	NS	ns1.example.net.
test.example.com.	300000	IN	NS	ns2.example.net.

My expectation is

A Record TTL: 600
NS TTL:300000

so i changed the code:

// /geodns/zones/reader.go#setupZoneData

var defaultTtl uint32 = 86400
if zone.Labels[k].Ttl > 0 {
	defaultTtl = uint32(zone.Labels[k].Ttl)
}
if r.RR.Header().Rrtype != dns.TypeNS {
	// NS records have special treatment. If they are not specified, they default to 86400 rather than
	// defaulting to the zone ttl option. The label TTL option always works though
	defaultTtl = uint32(zone.Options.Ttl)
}
if r.RR.Header().Ttl == 0 {
	r.RR.Header().Ttl = defaultTtl
}


//old code
var defaultTtl uint32 = 86400
if r.RR.Header().Rrtype != dns.TypeNS {
	// NS records have special treatment. If they are not specified, they default to 86400 rather than
	// defaulting to the zone ttl option. The label TTL option always works though
	defaultTtl = uint32(zone.Options.Ttl)
}
if zone.Labels[k].Ttl > 0 {
	defaultTtl = uint32(zone.Labels[k].Ttl)
}
if r.RR.Header().Ttl == 0 {
	r.RR.Header().Ttl = defaultTtl
}

dig result:

$ dig  test.example.com

;; QUESTION SECTION:
;test.example.com.		IN	A

;; ANSWER SECTION:
test.example.com.	  600	IN	A	192.168.0.1


$ dig ns test.example.com

;; QUESTION SECTION:
;test.example.com.		IN	NS

;; ANSWER SECTION:
test.example.com.	300000	IN	NS	ns1.example.net.
test.example.com.	300000	IN	NS	ns2.example.net.

Originally created by @pengyuu on GitHub (Mar 13, 2020). Original GitHub issue: https://github.com/abh/geodns/issues/118 I try to set NS ttl like this: test.example.com.json ```json { "serial":3, "ttl":600, "data":{ "":{ "ns":{ "ns1.example.net.":null, "ns2.example.net.":null }, "ttl":"300000" } } } ``` but A record ttl: ```sh $ dig test.example.com ;test.example.com. IN A ;; ANSWER SECTION: test.example.com. 300000 IN A 192.168.0.1 $ dig ns test.example.com ;; QUESTION SECTION: ;test.example.com. IN NS ;; ANSWER SECTION: test.example.com. 300000 IN NS ns1.example.net. test.example.com. 300000 IN NS ns2.example.net. ``` My expectation is ``` A Record TTL: 600 NS TTL:300000 ``` so i changed the code: ```go // /geodns/zones/reader.go#setupZoneData var defaultTtl uint32 = 86400 if zone.Labels[k].Ttl > 0 { defaultTtl = uint32(zone.Labels[k].Ttl) } if r.RR.Header().Rrtype != dns.TypeNS { // NS records have special treatment. If they are not specified, they default to 86400 rather than // defaulting to the zone ttl option. The label TTL option always works though defaultTtl = uint32(zone.Options.Ttl) } if r.RR.Header().Ttl == 0 { r.RR.Header().Ttl = defaultTtl } //old code var defaultTtl uint32 = 86400 if r.RR.Header().Rrtype != dns.TypeNS { // NS records have special treatment. If they are not specified, they default to 86400 rather than // defaulting to the zone ttl option. The label TTL option always works though defaultTtl = uint32(zone.Options.Ttl) } if zone.Labels[k].Ttl > 0 { defaultTtl = uint32(zone.Labels[k].Ttl) } if r.RR.Header().Ttl == 0 { r.RR.Header().Ttl = defaultTtl } ``` dig result: ```sh $ dig test.example.com ;; QUESTION SECTION: ;test.example.com. IN A ;; ANSWER SECTION: test.example.com. 600 IN A 192.168.0.1 $ dig ns test.example.com ;; QUESTION SECTION: ;test.example.com. IN NS ;; ANSWER SECTION: test.example.com. 300000 IN NS ns1.example.net. test.example.com. 300000 IN NS ns2.example.net. ```
Author
Owner

@abh commented on GitHub (Jun 4, 2025):

I wish I'd setup the configuration so all records could have metadata like this.

The problem here is that "ttl" is associated with the apex record ("") and not specifically with the A record, I think. Can you show a more complete configuration? (If this is still remotely relevant 5 years later! 🍭 )

<!-- gh-comment-id:2939176680 --> @abh commented on GitHub (Jun 4, 2025): I wish I'd setup the configuration so all records could have metadata like this. The problem here is that "ttl" is associated with the apex record ("") and not specifically with the A record, I think. Can you show a more complete configuration? (If this is still remotely relevant 5 years later! 🍭 )
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/geodns#370
No description provided.