Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A Record Ttl and NS Ttl #118

Open
pengyuu opened this issue Mar 13, 2020 · 0 comments
Open

A Record Ttl and NS Ttl #118

pengyuu opened this issue Mar 13, 2020 · 0 comments

Comments

@pengyuu
Copy link

pengyuu commented Mar 13, 2020

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant