AdguardTeam / dnsproxy

Simple DNS proxy with DoH, DoT, DoQ and DNSCrypt support
Apache License 2.0
2.37k stars 246 forks source link

No DNS right after boot up #275

Closed joshcangit closed 2 years ago

joshcangit commented 2 years ago

This dnsproxy needs to listen addresses to work but can't because if system-resolved.service is enabled, dnsproxy will have bind: permission denied. If I disable systemd-resolved.service, dnsproxy will then run.

But after boot up or reboot, DNS is gone. No URLs will work. This dnsproxy cannot initiate DNS resolution on boot up but systemd-resolved can. No, I have already set bootstrap addresses and enabled cache, still the same problem.

This bug is very difficult to describe. I hope this bug will get a fix eventually.

Temporary fix

  1. I made a dnsproxy.service so I had to disable that.
  2. Re-enable systemd-resolved.service.
  3. Do a network request, i.e., enter URL into browser.
  4. After that works, disable systemd-resolved.service again.
  5. Re-enable dnsproxy.service after that.

Finally, it looks like it works but after reboot or power off then power on, it comes back again every time.

saint-lascivious commented 2 years ago

After disabling systemd-resolved, who or what is managing /etc/resolv.conf? From the comments it doesn't appear to be you, or at least you haven't explicitly mentioned it.

In my experience it's easiest to just delete and recreate resolv.conf manually after disabling the service.

I myself run several parallel instances of dnsproxy via a service of my own construction and I can't say I can reproduce your issue.

joshcangit commented 2 years ago

After disabling systemd-resolved, who or what is managing /etc/resolv.conf? From the comments it doesn't appear to be you, or at least you haven't explicitly mentioned it.

I'm using Ubuntu. /etc/resolv.conf is managed by resolvconf.

saint-lascivious commented 2 years ago

I'm using Ubuntu as well.

Is your resolv.conf actually valid? The resolvconf service should leave resolv.conf alone if it's been manually created.

Once in a blue moon during a dist-upgrade it catches me out and my resolv.conf gets recreated (forgetting to mask the systemd-resolved service, and other shenanigans), but it's otherwise solid. I don't need/want any service to dynamically create resolv.conf, hence deleting it and creating my own.

joshcangit commented 2 years ago

I now found out how this doesn't work.

systemd-resolved uses 127.0.0.53. It adds this line to /etc/resolv.conf.

nameserver 127.0.0.53

So for dnsproxy, it needs to add a line with nameserver to /etc/resolv.conf for any listen address it uses.