https_dns_proxy icon indicating copy to clipboard operation
https_dns_proxy copied to clipboard

Consult the system hosts file when bootstrapping

Open sagan opened this issue 7 months ago • 1 comments

Hi.

I think it will be better if the bootstrapping process is able to resolve the resolver host ("dns.google") directly from system hosts file. Since the most popular public DoH providers have fixed IPs for their service domains, it is often beneficial to add these records to hosts file to speed up initialization.

  • Google: https://dns.google/dns-query => 8.8.8.8
  • CloudFlare: https://one.one.one.one/dns-query => 1.1.1.1

Currently, ares_gethostbyname does not consult the system hosts file, always sending query to the bootstrap DNS server.

To make c-ares use hosts file, when initializing c-ares using ares_init_options(), the char* lookups option of struct ares_options should be set to fb, which means consult the hosts file first, then resolve using DNS servers.

See: https://man.archlinux.org/man/ares_init_options.3.en#ARES_OPT_LOOKUPS

sagan avatar May 23 '25 06:05 sagan

Hi, later it could be implemented, but until no one would do it, I recommend to try: https://8.8.8.8/dns-query https://1.1.1.1/dns-query Because I recall that these should work. (Other DoH providers may not support this.) Br, Balázs

baranyaib90 avatar Jun 15 '25 09:06 baranyaib90