-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
UDP DNS: Bind to specific IP is not retained #724
Comments
[ Quoting <notifications@github.com> in "[miekg/dns] UDP DNS: Bind to specif..." ]
On MAC, we used the code
> dns.HandleFunc(".", handleDNSRequest)
> defer dns.HandleRemove(".")
> // start serverUDP
> serverUDP := &dns.Server{Addr: "127.0.0.1:53", Net: "udp"}
> go serverUDP.ListenAndServe()
> defer serverUDP.Shutdown()
It bound properly on specific IP and PORT as shown below:
udp4 0 0 127.0.0.1.53 *.*
But as soon as we write DNS response from handler function like
> msg.Authoritative = true
> domain := msg.Question[0].Name
> msg.Answer = append(msg.Answer, &dns.A{
> Hdr: dns.RR_Header{Name: domain, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 60},
> A: net.ParseIP("1.2.3.4"),
> })
> w.WriteMsg(&msg)
Binding changes to as shown below:
udp4 0 0 *.53 *.*
This impacts other DNS server which is running on another interface.
I debugged the UDP DNS code and figured out that after the below line is executed the binding changes
> ServerConn.WriteMsgUDP(b, oob, raddr)
Please let me know any more information is required such that this great code can be useful in case we wanted to bind to specific IP address and retain the binding
What does this break?
I have no idea why this could be happening, and without more debugging I don't
see a fix.
|
@jolakeng what IP address is the server receiving requests on? Is it Can you try adding a print line to |
This issue is reproducible with below sample UDP program, which I made similar to what is been used in DNS code
Output :
Bind before:
If don't give newOOB to WriteMsgUDP then binding is retained. |
Hi @james Hartig<mailto:notifications@github.com>
I printed received OOB, DST and Changed OOB in correctSource, here is the output
received OOB: [24 0 0 0 0 0 0 0 26 0 0 0 1 0 0 0 0 0 0 0 127 0 0 1]
DST: 127.0.0.1
new OOB: [24 0 0 0 0 0 0 0 26 0 0 0 0 0 0 0 127 0 0 1 0 0 0 0]
MAC is changing the binding once WriteMsgUDP is done with OOB. If OOB is nil, it’s not changing binding
Is there an issue with OOB we are providing?
Thanks
Joju
From: James Hartig <notifications@github.com>
Reply-To: miekg/dns <reply@reply.github.com>
Date: Thursday, August 16, 2018 at 10:19 PM
To: miekg/dns <dns@noreply.github.com>
Cc: "Olakengil, Joju" <jolakeng@akamai.com>, Mention <mention@noreply.github.com>
Subject: Re: [miekg/dns] UDP DNS: Bind to specific IP is not retained (#724)
correctSource
|
I'll try and do some more testing on a darwin system shortly, but I'm kind of stumped. It sounds like maybe it's a kernel bug. 🤷♂️ |
Do you think this could be related to #743? |
I don't believe this is an issue with this library, as such I'm closing this. |
On MAC, we used the code
It bound properly on specific IP and PORT as shown below:
udp4 0 0 127.0.0.1.53 .
But as soon as we write DNS response from handler function like
Binding changes to as shown below:
udp4 0 0 *.53 .
This impacts other DNS server which is running on another interface.
I debugged the UDP DNS code and figured out that after the below line is executed the binding changes
Please let me know any more information is required such that this great code can be useful in case we wanted to bind to specific IP address and retain the binding
cc: @fastest963
The text was updated successfully, but these errors were encountered: