Skip to content
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

Ability to select the dial address for resolvers #325

Open
alpominth opened this issue Aug 24, 2023 · 3 comments
Open

Ability to select the dial address for resolvers #325

alpominth opened this issue Aug 24, 2023 · 3 comments

Comments

@alpominth
Copy link

Many DoH, DoT and some DoQ resolvers have more than one IP for connecting:

$ host -t A dns.nextdns.io
dns.nextdns.io is an alias for steering.nextdns.io.
steering.nextdns.io has address 5.161.43.197
steering.nextdns.io has address 170.39.224.134

$ host -t A dns10.quad9.net
dns10.quad9.net has address 149.112.112.10
dns10.quad9.net has address 9.9.9.10

$ host -t A dns.cloudflare.com
dns.cloudflare.com has address 104.16.132.229
dns.cloudflare.com has address 104.16.133.229

$ host -t A dns-unfiltered.adguard.com
dns-unfiltered.adguard.com has address 94.140.14.140
dns-unfiltered.adguard.com has address 94.140.14.141

An option to specify which IP address will be used would be a good idea.

And maybe, RouteDNS could randomize the IP address selection to avoid overcharging the first IP address of a DoH|DoT|DoQ resolver. Maybe an option for doing that.

@cbuijs
Copy link
Contributor

cbuijs commented Aug 24, 2023

See also #56

@folbricht
Copy link
Owner

If no bootstrap-address is used, the selection should already be somewhat random. But as mentioned in #56, it'll not balance over requests, but over connections. So if you have a constant stream of queries going there it's likely going to keep using one connection. Once a timeout occurs, it'll re-dial which could end up on a different (or the same) address.

@cbuijs
Copy link
Contributor

cbuijs commented Sep 4, 2023

Maybe have the ability to use a resolver group for bootstrap as well, potentially create loops, but at least you can create any chain/resolution you want (with boot-strap-addresses).

How I do it now, I create a TCP listener on 127.0.0.1:53053 and point the bootstrap-resolver to it. A snippet of the config:

[bootstrap-resolver]
protocol = "tcp"
address = "127.0.0.1:53053"
query-timeout = 5

[listeners.bootstrap-do53-tcp]
address = "127.0.0.1:53053"
protocol = "tcp"
resolver = "bootstrap-dedup"

[groups.bootstrap-dedup]
type = "request-dedup"
resolvers = ["bootstrap-router"]

[routers.bootstrap-router]
routes = [
        {name = '(^|\.)dns\.server\.com\.$', type = "A", resolver = "bootstrap-a"},
        {name = '(^|\.)dns\.server\.com\.$', type = "AAAA", resolver = "bootstrap-aaaa"},

        {resolver = "nxdomain"},
]

[groups.bootstrap-a]
type = "static-responder"
rcode = 0
answer = [
        ". 3600 IN A 1.2.3.4",
        ". 3600 IN A 4.3.2.1",
        ". 3600 IN A 11.22.33.44",
]

[groups.bootstrap-aaaa]
type = "static-responder"
rcode = 0
answer = [
        ". 3600 IN AAAA 2001:db8::1:2:3:4",
        ". 3600 IN AAAA 2001:db8::4:3:2:1",
        ". 3600 IN AAAA 2001:db8::11:22:33:44",
]

[groups.nxdomain]
type = "static-responder"
rcode = 3

#### REST OF ROUTEDNS CONFIG BELOW ####

This as a construct example, you can build whatever you want with this. Be aware of loops though ;-).

-Chris.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants