[GH-ISSUE #2726] Missing bind_addr for resolving #1049

Closed
opened 2026-03-16 01:26:15 +03:00 by kerem · 0 comments
Owner

Originally created by @Arne91 on GitHub (Jan 16, 2025).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/2726

Describe the bug
I am using a modem to resolve the domain "google.com". For this, I set the binding address to the intern IP address of the modem, which I got from the dns client.
When I try to resolve, I got a timeout. In the version 0.22.1, it works.

[2025-01-16T10:52:01Z DEBUG hickory_resolver::name_server::name_server] reconnecting: NameServerConfig { socket_addr: 1.1.1.1:53, protocol: Udp, tls_dns_name: None, http_endpoint: None, trust_negative_responses: true, bind_addr: Some(192.168.225.56:0) }
[2025-01-16T10:52:01Z DEBUG hickory_proto::xfer] enqueueing message:QUERY:[Query { name: Name("google.com."), query_type: A, query_class: IN }]
[2025-01-16T10:52:01Z DEBUG hickory_proto::udp::udp_client_stream] final message: ; header 37604:QUERY:RD:NoError:QUERY:0/0/0
    ; query
    ;; google.com. IN A
    
[2025-01-16T10:52:01Z DEBUG hickory_proto::udp::udp_client_stream] bind_addr: None
[2025-01-16T10:52:01Z DEBUG hickory_proto::udp::udp_stream] created socket successfully

What I recognized is, that I set the NameServerConfig with bind_addr, but the bind_addr is here None.

To Reproduce
Steps to reproduce the behavior:

With following code:

#[cfg(test)]
mod test {
    use super::*;

    #[tokio::test]
    async fn google_cloudflare_resolver() {
        let resolver = Resolver::new(&[Ipv4Addr::new(8, 8, 8, 8), Ipv4Addr::new(1, 1, 1, 1)], Some(Ipv4Addr::new(0, 0, 0, 0))).unwrap();
        let ip = resolver.ipv4_lookup("www.google.com").await.expect("resolving www.google.com failed");
        println!("www.google.com is at {ip}");
    }
}

And a println! in crates/proto/src/udp/udp_client_stream.rs

impl<P: RuntimeProvider> DnsRequestSender for UdpClientStream<P> {
    fn send_message(&mut self, mut request: DnsRequest) -> DnsResponseStream {
    ...
    let bind_addr = self.bind_addr;
    println!("bind_addr: {bind_addr:?}");
    ...
}

I've got following output when I run the test:

test dns::resolver::test::google_cloudflare_resolver ... ok

successes:

---- dns::resolver::test::google_cloudflare_resolver stdout ----
bind_addr: None
bind_addr: None
www.google.com is at 142.251.209.132

Expected behavior
I expected, that the bind_addr is Some(0.0.0.0) and not None.

System:

  • OS: Ubuntu 22.04
  • Architecture: x86_64
  • Version: 22.04.5 LTS
  • rustc version: 1.82.0

Version:
Crate: hickory-resolver
Version: 0.25.0-alpha.4

Additional context
In the version 0.22.1, there was a usage of the bind_addr in the file crates/resolver/src/name_server/connection_provider.rs in the function new_connection(). This code was removed later. Why was this code been removed?


impl<R> ConnectionProvider for GenericConnectionProvider<R>
where
    R: RuntimeProvider,
    <R as RuntimeProvider>::Tcp: Connect,
{
    type Conn = GenericConnection;
    type FutureConn = ConnectionFuture<R>;
    type Time = R::Timer;

    /// Constructs an initial constructor for the ConnectionHandle to be used to establish a
    ///   future connection.
    fn new_connection(
        &self,
        config: &NameServerConfig,
        options: &ResolverOpts,
    ) -> Self::FutureConn {
        let dns_connect = match config.protocol {
            Protocol::Udp => {
                let stream = UdpClientStream::<R::Udp>::with_bind_addr_and_timeout(
                    config.socket_addr,
                    config.bind_addr,
                    options.timeout,
                );
                let exchange = DnsExchange::connect(stream);
                ConnectionConnect::Udp(exchange)
            }
Originally created by @Arne91 on GitHub (Jan 16, 2025). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/2726 **Describe the bug** I am using a modem to resolve the domain "google.com". For this, I set the binding address to the intern IP address of the modem, which I got from the dns client. When I try to resolve, I got a timeout. In the version 0.22.1, it works. ``` [2025-01-16T10:52:01Z DEBUG hickory_resolver::name_server::name_server] reconnecting: NameServerConfig { socket_addr: 1.1.1.1:53, protocol: Udp, tls_dns_name: None, http_endpoint: None, trust_negative_responses: true, bind_addr: Some(192.168.225.56:0) } [2025-01-16T10:52:01Z DEBUG hickory_proto::xfer] enqueueing message:QUERY:[Query { name: Name("google.com."), query_type: A, query_class: IN }] [2025-01-16T10:52:01Z DEBUG hickory_proto::udp::udp_client_stream] final message: ; header 37604:QUERY:RD:NoError:QUERY:0/0/0 ; query ;; google.com. IN A [2025-01-16T10:52:01Z DEBUG hickory_proto::udp::udp_client_stream] bind_addr: None [2025-01-16T10:52:01Z DEBUG hickory_proto::udp::udp_stream] created socket successfully ``` What I recognized is, that I set the NameServerConfig with bind_addr, but the bind_addr is here None. **To Reproduce** Steps to reproduce the behavior: With following code: ```rust #[cfg(test)] mod test { use super::*; #[tokio::test] async fn google_cloudflare_resolver() { let resolver = Resolver::new(&[Ipv4Addr::new(8, 8, 8, 8), Ipv4Addr::new(1, 1, 1, 1)], Some(Ipv4Addr::new(0, 0, 0, 0))).unwrap(); let ip = resolver.ipv4_lookup("www.google.com").await.expect("resolving www.google.com failed"); println!("www.google.com is at {ip}"); } } ``` And a println! in crates/proto/src/udp/udp_client_stream.rs ```rust impl<P: RuntimeProvider> DnsRequestSender for UdpClientStream<P> { fn send_message(&mut self, mut request: DnsRequest) -> DnsResponseStream { ... let bind_addr = self.bind_addr; println!("bind_addr: {bind_addr:?}"); ... } ``` I've got following output when I run the test: ``` test dns::resolver::test::google_cloudflare_resolver ... ok successes: ---- dns::resolver::test::google_cloudflare_resolver stdout ---- bind_addr: None bind_addr: None www.google.com is at 142.251.209.132 ``` **Expected behavior** I expected, that the bind_addr is Some(0.0.0.0) and not None. **System:** - OS: Ubuntu 22.04 - Architecture: x86_64 - Version: 22.04.5 LTS - rustc version: 1.82.0 **Version:** Crate: hickory-resolver Version: 0.25.0-alpha.4 **Additional context** In the version 0.22.1, there was a usage of the bind_addr in the file `crates/resolver/src/name_server/connection_provider.rs` in the function `new_connection()`. This code was removed later. Why was this code been removed? ```rust impl<R> ConnectionProvider for GenericConnectionProvider<R> where R: RuntimeProvider, <R as RuntimeProvider>::Tcp: Connect, { type Conn = GenericConnection; type FutureConn = ConnectionFuture<R>; type Time = R::Timer; /// Constructs an initial constructor for the ConnectionHandle to be used to establish a /// future connection. fn new_connection( &self, config: &NameServerConfig, options: &ResolverOpts, ) -> Self::FutureConn { let dns_connect = match config.protocol { Protocol::Udp => { let stream = UdpClientStream::<R::Udp>::with_bind_addr_and_timeout( config.socket_addr, config.bind_addr, options.timeout, ); let exchange = DnsExchange::connect(stream); ConnectionConnect::Udp(exchange) } ```
kerem closed this issue 2026-03-16 01:26:30 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#1049
No description provided.