<div dir="ltr">Hi,<div><br></div><div>I am running into a bug in the following circumstances.</div><div><br></div><div>When the config has a mix of the below (e.g. pick any 2 of 3, or pick all 3):</div><div><ol><li>dynamic-host entries with only IPv4 address fragments specified.</li><li>dynamic-host entries with only IPv6 address fragments specified.</li><li>dynamic-host entries with both IPv4 and IPv6 address fragments specified.</li></ol><div><div>Then the following occurs when querying DNS for PTR records:</div><div><ul><li>For IPv6 PTR records from dynamic-host, only IPv6 addresses whose dynamic-host entries are before the first IPv4-only dynamic-host entry can be resolved to name.  All IPv6 addresses whose entry is after the first IPv4-only entry cannot be resolved to name.</li><li>For IPv4 PTR records from dynamic-host, only IPv4 addresses whose dynamic-host entries are before the first IPv6-only dynamic-host entry can be resolved to name.  All IPv4 addresses whose entry is after the first IPv6-only entry cannot be resolved to name.</li></ul></div><div>The man page entry for dynamic-host shows both [IPv4-address] and [IPv6-address] in square brackets [], suggesting that it's perfectly acceptable to specify entries with only IPv4, only IPv6, or both IPv4+IPv6.  I haven't seen anything suggesting that they should not be mixed and matched.</div><div><br></div><div>This seems vaguely similar to the issue fixed by commit <a href="https://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=commit;h=f4c87b504b444efb05892b8c7fc295e886f70789">f4c87b504b444efb05892b8c7fc295e886f70789</a> back in February (I was originally testing with dnsmasq 2.85 before this fix and ran into this issue myself).  However I have confirmed this issue using dnsmasq from the Git repo as of 2022-07-22 (on both Raspberry Pi OS bullseye and Debian Sid) - well after this commit.<br></div><div><br></div><div>For context, the reason that I personally am running into this scenario is because I am using dnsmasq for DHCPv6 and DNS.  So I have:</div><div><br></div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div>(a) Some devices where I add a dhcp-host entry for IPv6 + a dynamic-host entry for only IPv4.<br>(I would be using host-record instead of dynamic-host as my IPv4 prefix is fixed, but I'm currently using dynamic-host as a workaround to another issue identified on this mailing list: <a href="https://www.mail-archive.com/dnsmasq-discuss@lists.thekelleys.org.uk/msg16336.html">With auth-zone enabled, DNS response only provides DHCPv6 IP and ignores IPv4 address/host-record entries</a>)<br>(b) Other devices where I add a single dynamic-host entry for both IPv4 and IPv6.</div></div></div></blockquote><div><div><br></div><div>The first (a) entry breaks reverse lookup for all IPv6 addresses in (b) entries.</div><div><br></div><div>PTR records added by other means work fine - for example from ptr-record or dhcp-host.  Therefore manually adding ptr-records is a workaround (although very tedious for IPv6!)<br></div><div><br></div><div><br></div><div>More detail and steps to reproduce:</div><div><br></div><div>(0) Consider the configuration below, with a mix of IPv4-only and IPv4+IPv6 entries:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><font face="monospace">no-resolv<br>dynamic-host=<a href="http://Computer1.example.org">Computer1.example.org</a>, 0.0.0.1, ::1, eth0<br>dynamic-host=<a href="http://Computer2.example.org">Computer2.example.org</a>, 0.0.0.2, eth0<br>dynamic-host=<a href="http://Computer3.example.org">Computer3.example.org</a>, 0.0.0.3, ::3, eth0<br>dynamic-host=<a href="http://Computer4.example.org">Computer4.example.org</a>, 0.0.0.4, eth0<br>dynamic-host=<a href="http://Computer5.example.org">Computer5.example.org</a>, 0.0.0.5, ::5, eth0</font><br></blockquote><div><div><br></div><div>Assume the local network is <a href="http://10.0.0.0/24">10.0.0.0/24</a> and fd50::/64, and eth0 is configured with IPs in these ranges.</div><div><br></div><div>(1) Looking up A records for all 5 names will return results for all 5 computers - as expected</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="monospace">$ dig @<a href="http://10.0.0.1">10.0.0.1</a> +short A <a href="http://Computer1.example.org">Computer1.example.org</a> <a href="http://Computer2.example.org">Computer2.example.org</a> <a href="http://Computer3.example.org">Computer3.example.org</a> <a href="http://Computer4.example.org">Computer4.example.org</a> <a href="http://Computer5.example.org">Computer5.example.org</a></font></div></div><div><div><font face="monospace">10.0.0.1</font></div></div><div><div><font face="monospace">10.0.0.2</font></div></div><div><div><font face="monospace">10.0.0.3</font></div></div><div><div><font face="monospace">10.0.0.4</font></div></div><div><div><font face="monospace">10.0.0.5</font></div></div></blockquote><div><div><br></div><div>(2) Looking up AAAA records for all 5 names will return results for Computer1, Computer3, and Computer5 - as expected</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="monospace">dig @<a href="http://10.0.0.1">10.0.0.1</a> +short AAAA <a href="http://Computer1.example.org">Computer1.example.org</a> <a href="http://Computer2.example.org">Computer2.example.org</a> <a href="http://Computer3.example.org">Computer3.example.org</a> <a href="http://Computer4.example.org">Computer4.example.org</a> <a href="http://Computer5.example.org">Computer5.example.org</a></font></div></div><div><div><font face="monospace">fd50::1</font></div></div><div><div><font face="monospace">fd50::3</font></div></div><div><div><font face="monospace">fd50::5</font></div></div></blockquote><div><div><br></div><div>(3) Looking up PTR records for all 5 IPv4 addresses will return names for all 5 computers - as expected</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="monospace">$ dig @<a href="http://10.0.0.1">10.0.0.1</a> +short -x 10.0.0.1 -x 10.0.0.2 -x 10.0.0.3 -x 10.0.0.4 -x 10.0.0.5</font></div></div><div><div><font face="monospace"><a href="http://Computer1.example.org">Computer1.example.org</a>.</font></div></div><div><div><font face="monospace"><a href="http://Computer2.example.org">Computer2.example.org</a>.</font></div></div><div><div><font face="monospace"><a href="http://Computer3.example.org">Computer3.example.org</a>.</font></div></div><div><div><font face="monospace"><a href="http://Computer4.example.org">Computer4.example.org</a>.</font></div></div><div><div><font face="monospace"><a href="http://Computer5.example.org">Computer5.example.org</a>.</font></div></div></blockquote><div><div><br></div><div>(4) However, looking up PTR records for all 3 IPv6 addresses will <b>only</b> return the name for Computer1.  This is not expected - all three names should be returned.</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="monospace">$ dig @<a href="http://10.0.0.1">10.0.0.1</a> +short -x </font><span style="font-family:monospace">fd50::1 -</span><font face="monospace">x </font><span style="font-family:monospace">fd50::3</span> <font face="monospace">-x</font><span style="font-family:monospace">fd50::5</span></div></div><div><div><font face="monospace"><a href="http://Computer1.example.org">Computer1.example.org</a>.</font></div></div></blockquote><div><div><br></div><div>What is happening is the existence and position of the entry for Computer2 is breaking reverse DNS lookup for Computer3/Computer5.</div><div><br></div><div>The behaviour is entirely affected by the order of the dynamic-host entries in the file.  For example, if you reverse the order of the dynamic-host entries in the config in (0), then only the name for Computer 5 is returned.</div><div><br></div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><div><div><div><font face="monospace">$ dig @<a href="http://10.0.0.1">10.0.0.1</a> +short -x</font> <span style="font-family:monospace">fd50::1 -</span><font face="monospace">x </font><span style="font-family:monospace">fd50::3</span> <font face="monospace">-x </font><span style="font-family:monospace">fd50::5<br></span><span style="font-family:monospace"><a href="http://Computer5.example.org">Computer5.example.org</a>.</span></div></div></div></div></div></div></blockquote><div><div><br></div><div>If you change the order so all IPv4+IPv6 entries are first (i.e. Computer1 > Computer3 > Computer5 > Computer2 > Computer4), then all IPv6 addresses can resolve to names:</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="monospace">$ dig @<a href="http://10.0.0.1">10.0.0.1</a> +short -x </font><span style="font-family:monospace">fd50::1 -</span><font face="monospace">x </font><span style="font-family:monospace">fd50::3</span> <font face="monospace">-x </font><span style="font-family:monospace">fd50::5<br></span></div></div><div><div><span style="font-family:monospace"><a href="http://Computer1.example.org">Computer1.example.org</a>.</span></div></div><div><div><span style="font-family:monospace"><a href="http://Computer3.example.org">Computer3.example.org</a>.</span></div></div><div><div><span style="font-family:monospace"><a href="http://Computer5.example.org">Computer5.example.org</a>.</span></div></div></blockquote><div><br></div>If you change the order so all IPv4-only entries are first (i.e. Computer 2 > Computer 4 > Computer 1 > Computer 3 > Computer 5), then no IPv6 addresses can resolve to names at all.<div><br><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace">$ dig @<a href="http://10.0.0.1">10.0.0.1</a> +short -x </font> <span style="font-family:monospace">fd50::1 -</span><font face="monospace">x </font> <span style="font-family:monospace">fd50::3</span> <font face="monospace">-x </font><span style="font-family:monospace">fd50::5</span></div></blockquote><br>(5) For the reverse of (0)-(4) - a mix of IPv6-only and IPv4+IPv6 entries - the reverse problem occurs:</div><div><br><div>Config:</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="monospace">no-resolv</font></div></div><div><div><font face="monospace">dynamic-host=<a href="http://Computer1.example.org">Computer1.example.org</a>, 0.0.0.1, ::1, eth0</font></div></div><div><div><font face="monospace">dynamic-host=<a href="http://Computer2.example.org">Computer2.example.org</a>, ::2, eth0</font></div></div><div><div><font face="monospace">dynamic-host=<a href="http://Computer3.example.org">Computer3.example.org</a>, 0.0.0.3, ::3, eth0</font></div></div><div><div><font face="monospace">dynamic-host=<a href="http://Computer4.example.org">Computer4.example.org</a>, ::4, eth0</font></div></div><div><div><font face="monospace">dynamic-host=<a href="http://Computer5.example.org">Computer5.example.org</a>, 0.0.0.5, ::5, eth0</font></div></div></blockquote><div><div><br></div></div><div>IPv4 PTR records broken (only returns those before Computer2)<br></div><div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="monospace">$ dig @<a href="http://10.0.0.1">10.0.0.1</a> +short -x 10.0.0.1 -x 10.0.0.3 -x 10.0.0.5</font></div></div><div><div><font face="monospace"><a href="http://Computer1.example.org">Computer1.example.org</a>.</font></div></div></blockquote><div><div><br></div><div>(7) For a mix of IPv4-only and IPv6-only entries, the same problem occurs for both:</div><div><br></div><div>Config:</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="monospace">no-resolv</font></div></div><div><div><font face="monospace">dynamic-host=<a href="http://Computer1.example.org">Computer1.example.org</a>, ::1, eth0</font></div></div><div><div><font face="monospace">dynamic-host=<a href="http://Computer2.example.org">Computer2.example.org</a>, 0.0.0.2, eth0</font></div></div><div><div><font face="monospace">dynamic-host=<a href="http://Computer3.example.org">Computer3.example.org</a>, ::3, eth0</font></div></div><div><div><font face="monospace">dynamic-host=<a href="http://Computer4.example.org">Computer4.example.org</a>, 0.0.0.4, eth0</font></div></div><div><div><font face="monospace">dynamic-host=<a href="http://Computer5.example.org">Computer5.example.org</a>, ::5, eth0</font></div></div></blockquote><div><div><br></div><div><div>IPv4 PTR records broken (only returns those before Computer1 - i.e. none)<br></div><div><div><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><font face="monospace">$ dig @<a href="http://10.0.0.1">10.0.0.1</a> +short -x 10.0.0.2 -x 10.0.0.4</font></div></div></blockquote></div><div><br></div><div>IPv6 PTR records broken (only returns those before Computer2)</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><div><font face="monospace">$ dig @<a href="http://10.0.0.1">10.0.0.1</a> +short -x </font> <span style="font-family:monospace">fd50::1 -</span><font face="monospace">x </font> <span style="font-family:monospace">fd50::3</span> <font face="monospace">-x </font><span style="font-family:monospace">fd50::5</span></div></div></div></div><div><div><div><div><font face="monospace"><a href="http://Computer1.example.org">Computer1.example.org</a>.</font></div></div></div></div></blockquote><div><div><br></div><div><br></div><div>Hope this is all clear!</div><div><br>Kind regards,<div><div>ryt51v</div></div></div></div></div>