Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hello,

I would like to return a CNAME with value sinkhole.domain.xx if the A request is made on not allowed domain.

Basically, if my plugin receives a A request for baddomain.xyz, I would like to return a CNAME to sinkhole.abc

This is what I tried:

`
state := request.Request{W: w, Req: r}

answers := []dns.RR{}

cn := new(dns.CNAME)
cn.Hdr = dns.RR_Header{Name: state.Name(), Rrtype: dns.TypeCNAME, Class: dns.ClassINET, Ttl: 300}
cn.Target = "sinkhole.domain.xx"
answers = append(answers, cn)

switch state.Type() {
case "A":
	rr := new(dns.A)
	rr.Hdr = dns.RR_Header{Name: "sinkhole.domain.xx", Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 300}
	rr.A = net.ParseIP(sinkHoleIpv4)
	answers = append(answers, rr)
case "AAAA":
	rr := new(dns.AAAA)
	rr.Hdr = dns.RR_Header{Name: "sinkhole.domain.xx", Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: 300}
	rr.AAAA = net.ParseIP(sinkHoleIpv6)
	answers = append(answers, rr)
}


m := new(dns.Msg)
m.SetReply(r)
m.Question[0].Name = "sinkhole.domain.xx
m.Authoritative = true
m.Answer = answers

w.WriteMsg(m)
return dns.RcodeSuccess

Unfortunatly, I see a response in the console:
[INFO] 127.0.0.1:43986 - 49064 "A IN 0-1x.8632152.xyz. udp 34 false 512" NOERROR qr,aa,rd 112 0.000613969s
`

But nothing on the network... and so my nslookup returns:

`

0-1x.8632152.xyz
;; communications error to 127.0.0.1#1053: timed out
;; communications error to 127.0.0.1#1053: timed out
;; communications error to 127.0.0.1#1053: timed out
;; no servers could be reached

`

Do you have an idea what I'm doing wrong ?

THanks for your feedback.

You must be logged in to vote

Replies: 1 comment · 1 reply

Comment options

you should not change the question name in response, it should be the same as in query

You must be logged in to vote
1 reply
@nicolasbeusen
Comment options

Thanks for feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.