-
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
Send UDP DNS responses from the address we received them from #95
Comments
Bert from PowerDNS blogged about this a while back. It's the wrong end of the day for me so I haven't refreshed myself on the details or dug into go's syscall/net interfaces to see how much trouble it'd be. I'll take a look tomorrow if no one else does. |
Some magic syscall.SetsockOptInt might do the trick. I have a bug open for this on skydns as well |
I've played with this a bit, got it working on Linux, but not on OSX. Here is my progress: |
[ Quoting notifications@github.com in "Re: [dns] Send UDP DNS responses fr..." ]
And the magic there is this line?
Sadly not portable as you say. I wonder if this is a broader Go UDP issue, i.e. if we should look Thanks for your effort(s), I might have some time this weekend to also look /Miek Miek Gieben |
Not that simple. You should also be using According to Google (and the BSD man pages), the exact same implementation should be working with OSX, just by changing the syscall.SetsockoptInt(int(file.Fd()), syscall.IPPROTO_IP, syscall.IP_RECVDSTADDR, 1) But it returns syscall.SetsockoptByte(int(file.Fd()), syscall.IPPROTO_IP, syscall.IP_RECVDSTADDR, 1) But it yields the same results ( As for the Go way of solving this - I couldn't find any, but maybe the force is just stronger with you :) Waiting for your feedback. Thanks |
Hmm. Thanks for the thorough update. To frame the problem state properly: this is only a problem when listening But I also agree a elegant solution would be nice.
|
Another update: :) |
@miekg how would you feel about it if I'd fix it only for Linux (preserving the old behavior for OSX)? |
[ Quoting notifications@github.com in "Re: [dns] Send UDP DNS responses fr..." ]
I think that is OK and having an pull request make it easier to reason about it. It might be worth putting this in a seperate file to make it easier to contain /Miek Miek Gieben |
I have a problem with a server that has multiple IP address and is bound to 0.0.0.0.
I expect the DNS queries to be responded from the source IP address it was received on, but because of the way a UDP socket works when it's bound to 0.0.0.0, the OS is choosing the source IP when calling WriteTo().
For example,
host(1)
won't handle the response properly if it wasn't received from the destination address the query was sent to.See this stackoverflow message for more information about this UDP problem:
http://stackoverflow.com/questions/3062205/setting-the-source-ip-for-a-udp-socket
So:
Thanks.
The text was updated successfully, but these errors were encountered: