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

Enable DNS response compression #1109

Closed
aksdb opened this issue Oct 22, 2019 · 1 comment
Closed

Enable DNS response compression #1109

aksdb opened this issue Oct 22, 2019 · 1 comment
Assignees
Milestone

Comments

@aksdb
Copy link

aksdb commented Oct 22, 2019

Expected Behavior

After enabling AdGuardHome as my main DNS server via DHCP, all devices in my network should still work but receive properly filtered DNS responses.

Actual Behavior

Two devices (a media receiver for IPTV and an electronic door lock) refuse to connect and report network errors. All other devices work fine.

Solution

I played around by putting dnsmasq in front of AdGuardHome and suddenly the two devices in question started working again.
I therefore took Wireguard to analyze what the difference is in the answers I get. And apparently it's only a small thing: with AdGuardHome DNS responses are not compressed, with dnsmasq they are. That means, that the default responses from AdGuardHome are larger and contain the domain name twice (once in the question section and once in the answer section), while with dnsmasq (and apparently most other DNS servers out there) the answer section contains only a pointer into the question section.

So I enabled compression in AdGuardHome:

diff --git a/dnsforward/dnsforward.go b/dnsforward/dnsforward.go
index d2acb04..d9f8b14 100644
--- a/dnsforward/dnsforward.go
+++ b/dnsforward/dnsforward.go
@@ -441,6 +441,8 @@ func (s *Server) handleDNSRequest(p *proxy.Proxy, d *proxy.DNSContext) error {
                }
        }
 
+       d.Res.Compress = true
+
        shouldLog := true
        msg := d.Req

Now all devices in my home are happy.

Additional information

I guess this is somewhere between a bug and a feature, and most likely the actual bug is in one of the client implementations that those two devices use. Since all other DNS servers I tried compress their packets (makes sense I guess, given the max UDP packet size), I presume this small change does not hurt (quite the contrary, probably).

If you prefer a PR instead of this one-line-diff, I can certainly offer that as well. But I guess from a contribution perspective, this ticket with the one-line-diff is easier for you to apply :-)

@ameshkov
Copy link
Member

Nice, thank you!

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

No branches or pull requests

3 participants