AdguardTeam / dnsproxy

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

[error] dnsproxy: unpacking udp packet: dns: overflowing header size when using dnsmasq --use-stale-cache #327

Closed cattyhouse closed 1 year ago

cattyhouse commented 1 year ago

STEPS TO REPRODUCE

on gateway (dhcp server)

  1. dnsproxy listens on gateway -l 0.0.0.0 -p 53888, dnsmasq listen on 53 and uses dnsproxy as upstream

on client

  1. systemd-networkd
[Match]
Name=en*
[Network]
DHCP=yes
  1. systemd-resolved
systemctl enable --now systemd-resolved
ln -rsf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
  1. resolvectl output
...
Current DNS Server: GATEWAY_IP_ADDR
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
...
  1. dig api.github.com

on gateway (dhcp server)

log from gateway (dhcp server)

...
[error] dnsproxy: unpacking udp packet: dns: overflowing header size 
...
ameshkov commented 1 year ago

Could you please use tcpdump on gateway and check what exactly is received by dnsproxy?

cattyhouse commented 1 year ago

sorry, i did not mention dnsmasq in front of dnsproxy. further digging it is due to dnsmasq's

--use-stale-cache[=<max TTL excess in s>]
              When set, if a DNS name exists in the cache, but its time-to-live has expired, dnsmasq
              will  return  the data anyway. (It attempts to refresh the data with an upstream query
              after returning the stale data.) This can improve speed and reliability. It  comes  at
              the  expense of sometimes returning out-of-date data and less efficient cache utilisa‐
              tion, since old data cannot be flushed when its TTL  expires,  so  the  cache  becomes
              mostly  least-recently-used.  To  mitigate  issues  caused  by  massively outdated DNS
              replies, the maximum overaging of cached records can be specified in seconds (default‐
              ing  to  not  serve  anything older than one day). Setting the TTL excess time to zero
              will serve stale cache data regardless how long it has expired.

Could you please use tcpdump on gateway and check what exactly is received by dnsproxy?

cattyhouse commented 1 year ago

close, due to not related to dnsproxy, turn off dnsmasq's --use-stale-cache, this error does not happen again.