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
Bind address in ResolverConfig does not take effort for AsyncResolver #2190
Comments
IIRC a UDP DNS client doesn't bind to a single address (it uses ~one address per query) because otherwise it would be to easy to spoof responses. Why is it important that UDP messages come from a single address? What's the use case for this? |
I am agree with you that most of time, we don't need to bind a specific iface to do dns query. But sometimes we need, when I have more than one ifaces in my machine, which connect different networks. And also, it is a feature that we can bind a specific iface, that means we can bind a specific iface if we want. For most network library for example tokio, socket2, as you see, they all support this feature. Thanks. |
@bluejekyll maybe |
I think it should take a SocketAddr, because most of other library take a SocketAddr. for example, glibc, tokio. https://www.gnu.org/software/libc/manual/html_node/Setting-Address.html And more, in hickory dns, we have used SocketAddr for bind_addr, see: Thanks. |
IMO using a |
Most of cases, the users specific the port to 0 which means random port by system. See: https://github.com/hickory-dns/hickory-dns/blob/main/crates/proto/src/udp/udp_stream.rs#L291 |
It doesn't feel like you're actually reading my comments, so I'm going to stop engaging with this issue now. |
Looking at this more, I think @djc, is making a very good point that for this interface, we want a bind_addr that is just the IP address, and not the port. The port should be randomly chosen based on our logic which works to enforce a random port is always used for each connection. For that reason, I think we want the PR to continue to use the random port logic that we have, but allow for the bind address to be set. |
|
Not sure why you wanted to close this? My sense is that allowing the bind address is a good thing. We don’t trust the OS to distribute the port addresses in general, which is why the library has a random function to ensure it’s somewhat randomly distributed across the port space. I see that you believe we should accept SocketAddr and use the port as an indication of using random selection logic, and I get your reasoning, but in this case we will be issuing multiple requests from this interface. In order to issue multiple requests to the same remote address, those must be on separate ports, otherwise we run afoul of the response spoofing that the random port selection is intended to prevent. so it leads me to believe that we want to guide people in the proper direction, and only take IpAdrr as the bind address, and always randomize the port. Do you have a particular use case where you want the port to be static and non-zero ever? |
Describe the bug
A clear and concise description of what the bug is.
When I set bind_addr in ResolverConfig when make AsyncResolver, I expect that the UDP packets of DNS query would bind this SocketAddr, But it does not work!
To Reproduce
Steps to reproduce the behavior:
Source Code
Dependencies of Cargo.toml
Build and run
Expected behavior
A clear and concise description of what you expected to happen.
The last line of log should use bind_addr: 192.168.1.109:64665
System:
Version:
Crate: [e.g. client, server, resolver]
Version: [e.g. 0.9.1]
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: