NLnetLabs / unbound

Unbound is a validating, recursive, and caching DNS resolver.
https://nlnetlabs.nl/unbound
BSD 3-Clause "New" or "Revised" License
3.14k stars 358 forks source link

send request to all upstream servers #167

Open zhaibin18 opened 4 years ago

zhaibin18 commented 4 years ago

I have the forward-zone config like this: forward-zone: name: "." forward-addr: 8.8.8.8 forward-addr: 9.9.9.9

I hope unbound will send all dns request to 8.8.8.8 and 9.9.9.9, then return the first answer to the client.

In dnsmasq with all-servers config --all-servers By default, when dnsmasq has more than one upstream server available, it will send queries to just one server. Setting this flag forces dnsmasq to send all queries to all available servers. The reply from the server which answers first will be returned to the original requester.

ralphdolmans commented 4 years ago

Hi,

I am reluctant to implement such functionality, as this will generate way more traffic than needed.

Right now Unbound uses the same algorithm to select a forwarder as when sending queries upstream. Unbound will, over time, learn how responsive an upstream is. It will randomly select from all servers that are not more than 400ms away from the fastest. Details about that can be found at https://nlnetlabs.nl/documentation/unbound/info-timeout/

For anycasted servers like the ones you are using, they will probably both be in the 400ms RTT band, meaning they will both be used. Note that the default upstream selection algorithm can be adjusted using the fast-server-permil and fast-server-num configuration options.

zhaibin18 commented 4 years ago

Hi,

I am reluctant to implement such functionality, as this will generate way more traffic than needed.

Right now Unbound uses the same algorithm to select a forwarder as when sending queries upstream. Unbound will, over time, learn how responsive an upstream is. It will randomly select from all servers that are not more than 400ms away from the fastest. Details about that can be found at https://nlnetlabs.nl/documentation/unbound/info-timeout/

For anycasted servers like the ones you are using, they will probably both be in the 400ms RTT band, meaning they will both be used. Note that the default upstream selection algorithm can be adjusted using the fast-server-permil and fast-server-num configuration options.

Many thanks to your reply,in my config 8.8.8.8 and 9.9.9.9 are some examples, The DNS server from my ISP grow up to 3s for response sometimes,So please add an options for sending DNS request to all upstream servers and use the first reply immediately.

ralphdolmans commented 4 years ago

But in that case the 400ms RTT banding should be fine, right? Unbound will see that one of the upstreams is more than 400msec slower than the fastest upstream, and therefore eventually exclude it from the server selection for some time.

zhaibin18 commented 4 years ago

compare with smartdns(https://github.com/pymumu/smartdns), the unbound response time is 7-8 ms and smartdns response time is 2-3 ms with same upstream dns server.

LittleGrocery commented 4 years ago

compare with smartdns(https://github.com/pymumu/smartdns), the unbound response time is 7-8 ms and smartdns response time is 2-3 ms with same upstream dns server.

Since you already know smartdns, I think you can assemble your own dns server likes below(if your operating system is Linux or win10):

DNS query process:your computer→smartdns→unbound

→mainland china address whitelist→your isp dns server

→other address→dnscrypt proxy(doh)(socks or HTTP proxy already support if you need)→self-define doh server

I think this can tremendously improve your experience of web surfing.