How does the server decide which upstream provider to use? #845

Closed
opened 2026-03-04 00:52:07 -05:00 by deekerman · 4 comments
Owner

Originally created by @jamesponddotco on GitHub (Aug 7, 2019).

Hey 👋🏻,

If I am running AdGuard Home on a VPS with several DNSCrypt providers, how does the service decide which upstream to use for a query?

Let us say that the server running AdGuard Home is hosted in Iceland, I am based in Argentina, and I have upstream providers based in Japan, Australia, USA, Netherlands, Argentina and Iceland.

Will AdGuard Home choose the provider closest to me, i.e. the one in Argentina, closest to the server where it is deployed, i.e. Iceland, or at random? In my tests, it seems random, but I might be testing wrong — using dnsleaktest.com.

With the server in Germany, me being in Brazil and using DNSCrypt servers I have around the globe, dnsleaktest.com sometimes show the Brazilian server, sometimes the Tokyo one, sometimes the one from Miami and so on.

Thanks for the great project, by the way!

Originally created by @jamesponddotco on GitHub (Aug 7, 2019). Hey 👋🏻, If I am running AdGuard Home on a VPS with several DNSCrypt providers, how does the service decide which upstream to use for a query? Let us say that the server running AdGuard Home is hosted in Iceland, I am based in Argentina, and I have upstream providers based in Japan, Australia, USA, Netherlands, Argentina and Iceland. Will AdGuard Home choose the provider closest to me, *i.e. the one in Argentina*, closest to the server where it is deployed, *i.e. Iceland*, or at random? In my tests, it seems random, but I might be testing wrong — using [dnsleaktest.com](dnsleaktest.com). With the server in Germany, me being in Brazil and using DNSCrypt servers I have around the globe, [dnsleaktest.com](dnsleaktest.com) sometimes show the Brazilian server, sometimes the Tokyo one, sometimes the one from Miami and so on. Thanks for the great project, by the way!
deekerman 2026-03-04 00:52:07 -05:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@ameshkov commented on GitHub (Aug 7, 2019):

If I am running AdGuard Home on a VPS with several DNSCrypt providers, how does the service decide which upstream to use for a query?

Here you can take a look:
https://github.com/AdguardTeam/dnsproxy/blob/master/proxy/proxy.go#L425

Upstreams are sorted by the average round-trip-time, the one with the lowest value will be used.
If RTT values for your servers are close to each other, this might look like random.

@ameshkov commented on GitHub (Aug 7, 2019): > If I am running AdGuard Home on a VPS with several DNSCrypt providers, how does the service decide which upstream to use for a query? Here you can take a look: https://github.com/AdguardTeam/dnsproxy/blob/master/proxy/proxy.go#L425 Upstreams are sorted by the average round-trip-time, the one with the lowest value will be used. If RTT values for your servers are close to each other, this might look like random.
Author
Owner

@jamesponddotco commented on GitHub (Aug 7, 2019):

Hey @ameshkov,

Thanks for the reply!

Is the average round-trip-time compared to the server where AdGuard Home is installed or compared to the location of the client? I am guessing it is the server — which explains why the DNSCrypt server in Brazil is rarely used.

@jamesponddotco commented on GitHub (Aug 7, 2019): Hey @ameshkov, Thanks for the reply! Is the average round-trip-time compared to the server where AdGuard Home is installed or compared to the location of the client? I am guessing it is the server — which explains why the DNSCrypt server in Brazil is rarely used.
Author
Owner

@ameshkov commented on GitHub (Aug 7, 2019):

Is the average round-trip-time compared to the server where AdGuard Home is installed or compared to the location of the client?

Well, to put it simply, AGH just measures the time from sending the request to receiving the response and calls this RTT:) So yeah, if the server is far from AGH, the RTT will be higher.

@ameshkov commented on GitHub (Aug 7, 2019): > Is the average round-trip-time compared to the server where AdGuard Home is installed or compared to the location of the client? Well, to put it simply, AGH just measures the time from sending the request to receiving the response and calls this RTT:) So yeah, if the server is far from AGH, the RTT will be higher.
Author
Owner

@jamesponddotco commented on GitHub (Aug 7, 2019):

I am assuming DNSCrypt-Proxy works in a similar fashion, which explains why I get similar results when using Pi-hole with that.

Thanks, that explains a lot!

@jamesponddotco commented on GitHub (Aug 7, 2019): I am assuming [DNSCrypt-Proxy](https://github.com/jedisct1/dnscrypt-proxy) works in a similar fashion, which explains why I get similar results when using Pi-hole with that. Thanks, that explains a lot!
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/AdGuardHome#845
No description provided.