<div dir="ltr"><div>The problem of BIND ignoring "packets received correctly" has definitely something to do with queries using UDP packets.<br></div><div></div><div><br></div><div>Here's an example:<br></div><div><br></div><div># dig +nssearch <a href="http://EXAMPLE.COM">EXAMPLE.COM</a><br>SOA <a href="http://ns1.DOMAIN.com">ns1.DOMAIN.com</a>. <a href="http://hostmaster.DOMAIN.com">hostmaster.DOMAIN.com</a>. 2021010707 3600 600 2419200 600 from server M.N.O.P in 3 ms.<br>SOA <a href="http://ns1.DOMAIN.com">ns1.DOMAIN.com</a>. <a href="http://hostmaster.DOMAIN.com">hostmaster.DOMAIN.com</a>. 2021010707 3600 600 2419200 600 from server Q.R.S.T in 3 ms.<br>SOA <a href="http://ns1.DOMAIN.com">ns1.DOMAIN.com</a>. <a href="http://hostmaster.DOMAIN.com">hostmaster.DOMAIN.com</a>. 2021010707 3600 600 2419200 600 from server U.V.W.X in 3 ms.<br>;; no response from A.B.C.D<br><br>
Forcing queries to use TCP makes BIND not to ignore any QUERY

(never)<br><br># dig +tcp +nssearch <a href="http://EXAMPLE.COM">EXAMPLE.COM</a><br>SOA <a href="http://ns1.DOMAIN.com">ns1.DOMAIN.com</a>. <a href="http://hostmaster.DOMAIN.com">hostmaster.DOMAIN.com</a>. 2021010707 3600 600 2419200 600 from server A.B.C.D in 0 ms.<br>SOA <a href="http://ns1.DOMAIN.com">ns1.DOMAIN.com</a>. <a href="http://hostmaster.DOMAIN.com">hostmaster.DOMAIN.com</a>. 2021010707 3600 600 2419200 600 from server E.F.G.H in 0 ms.<br>SOA <a href="http://ns1.DOMAIN.com">ns1.DOMAIN.com</a>. <a href="http://hostmaster.DOMAIN.com">hostmaster.DOMAIN.com</a>. 2021010707 3600 600 2419200 600 from server I.J.K.L in 0 ms.<br>SOA <a href="http://ns1.DOMAIN.com">ns1.DOMAIN.com</a>. <a href="http://hostmaster.DOMAIN.com">hostmaster.DOMAIN.com</a>. 2021010707 3600 600 2419200 600 from server M.N.O.P in 3 ms.<br>SOA <a href="http://ns1.DOMAIN.com">ns1.DOMAIN.com</a>. <a href="http://hostmaster.DOMAIN.com">hostmaster.DOMAIN.com</a>. 2021010707 3600 600 2419200 600 from server Q.R.S.T in 3 ms.<br>SOA <a href="http://ns1.DOMAIN.com">ns1.DOMAIN.com</a>. <a href="http://hostmaster.DOMAIN.com">hostmaster.DOMAIN.com</a>. 2021010707 3600 600 2419200 600 from server U.V.W.X in 3 ms.</div><div><br></div><div>Again, I would appreciate if anybody can help with this or give some hint.

</div></div><div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br> <table style="border-top:1px solid #d3d4de">
        <tr>
      <td style="width:55px;padding-top:18px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;"></a></td>
                <td style="width:470px;padding-top:17px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Libre de virus. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank" style="color:#4453ea">www.avast.com</a>               </td>
        </tr>
</table>
<a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">El jue, 7 ene 2021 a las 16:56, - (<<a href="mailto:bernardo.pons@gmail.com">bernardo.pons@gmail.com</a>>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi all,</div><div><br></div><div>We are running BIND 9.16.6 DNS servers that are receiving queries from clients but randomly ignore "packets received correctly" as shown in this logs.</div><br>When the DNS server answers the query, BIND is logging this:<br><br>30-Dec-2020 10:16:55.071 client: debug 3: client @0x7f9808000c80 A.B.C.D#47290: UDP request<br>30-Dec-2020 10:16:55.071 client: debug 5: client @0x7f9808000c80 A.B.C.D#47290: using view '_default'<br>30-Dec-2020 10:16:55.071 security: debug 3: client @0x7f9808000c80 A.B.C.D#47290: request is not signed<br>30-Dec-2020 10:16:55.071 security: debug 3: client @0x7f9808000c80 A.B.C.D#47290: recursion available<br>30-Dec-2020 10:16:55.071 queries: info: client @0x7f9808000c80 A.B.C.D#47290 (<a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>): query: <a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a> IN SOA -E(0)K (E.F.G.H)<br>30-Dec-2020 10:16:55.071 security: debug 3: client @0x7f9808000c80 A.B.C.D#47290 (<a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>): query '<a href="http://EXAMPLE.COM/SOA/IN" target="_blank">EXAMPLE.COM/SOA/IN</a>' approved<br>30-Dec-2020 10:16:55.071 rate-limit: debug 99: client @0x7f9808000c80 A.B.C.D#47290 (<a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>): rrl=0x7f9810365a20, HAVECOOKIE=0, result=ISC_R_SUCCESS, fname=0x7f9814d523d0(1), is_zone=1, RECURSIONOK=0, query.rpz_st=(nil)(0), RRL_CHECKED=0<br>30-Dec-2020 10:16:55.071 security: debug 3: client @0x7f9808000c80 A.B.C.D#47290 (<a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>): reset client<br><br>while TCPDUMP output (command "tcpdump -i eth0 port 53 -n -vvv") is showing this:<br><br>A.B.C.D.47290 > E.F.G.H.53: [udp sum ok] 47783 [1au] SOA? <a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>. ar: . OPT UDPsize=4096 (49)<br>E.F.G.H.53 > A.B.C.D.47290: [bad udp cksum 0x3f6d -> 0x7b61!] 47783* q: SOA? <a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>. 1/6/1 <a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>. [1h] SOA <a href="http://ns1.DOMAIN.COM" target="_blank">ns1.DOMAIN.COM</a>. <a href="http://dns.DOMAIN.COM" target="_blank">dns.DOMAIN.COM</a>. 2020122901 3600 600 2419200 600 ns: <a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>. [1d] NS <a href="http://ns3.DOMAIN.NET" target="_blank">ns3.DOMAIN.NET</a>., <a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>. [1d] NS <a href="http://ns2.DOMAIN.NET" target="_blank">ns2.DOMAIN.NET</a>., <a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>. [1d] NS <a href="http://ns1.DOMAIN.COM" target="_blank">ns1.DOMAIN.COM</a>., <a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>. [1d] NS <a href="http://ns3.DOMAIN.COM" target="_blank">ns3.DOMAIN.COM</a>., <a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>. [1d] NS <a href="http://ns1.DOMAIN.NET" target="_blank">ns1.DOMAIN.NET</a>., <a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>. [1d] NS <a href="http://ns2.DOMAIN.COM" target="_blank">ns2.DOMAIN.COM</a>. ar: . OPT UDPsize=4096 (246)<br><br>So far, everything's fine.<br><br>But, when the DNS server doesn't answer the query, BIND is logging this:<br><br>30-Dec-2020 10:16:47.487 general: debug 60: socket 0x7f9815aa2178 A.B.C.D#36113: packet received correctly<br>30-Dec-2020 10:16:48.487 general: debug 60: socket 0x7f9815aa2178 A.B.C.D#36113: packet received correctly<br>30-Dec-2020 10:16:48.487 general: debug 60: socket 0x7f9815aa2178 A.B.C.D#36113: packet received correctly<br>30-Dec-2020 10:16:49.491 general: debug 60: socket 0x7f9815aa2178 A.B.C.D#36113: packet received correctly<br><br>while TCPDUMP output is showing this:<br><br>A.B.C.D.36113 > E.F.G.H.53: [udp sum ok] 13628 [1au] SOA? <a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>. ar: . OPT UDPsize=4096 (49)<br>A.B.C.D.36113 > E.F.G.H.53: [udp sum ok] 13628 [1au] SOA? <a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>. ar: . OPT UDPsize=4096 (49)<br>A.B.C.D.36113 > E.F.G.H.53: [udp sum ok] 13628 [1au] SOA? <a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>. ar: . OPT UDPsize=4096 (49)<br>A.B.C.D.36113 > E.F.G.H.53: [udp sum ok] 13628 [1au] SOA? <a href="http://EXAMPLE.COM" target="_blank">EXAMPLE.COM</a>. ar: . OPT UDPsize=4096 (49)<br><br>UDP packets received in both cases are the same but BIND randomly ignores them sometimes (causing the client to query again) and finally it never answers the query received in the first time.<br><br>The host CPU, memory and NIC utilization are low so it's very unlikely that computing resource bottlenecks are causing packets to be dumped.<br>In fact, command "netstat -suna" shows that apparently the host has no problem processing UDP packets.<br><br>Udp:<br>    1349954 packets received<br>    27 packets to unknown port received<br>    0 packet receive errors<br>    631757 packets sent<br>    0 receive buffer errors<br>    0 send buffer errors<br><br>It's a little bit surprising that "packet received correctly" is only being logged when things go wrong.<br>The only place in the code that I've found where "packet received correctly" is being logged is here at socket.c<br><br>        /*<br>         * On TCP and UNIX sockets, zero length reads indicate EOF,<br>         * while on UDP sockets, zero length reads are perfectly valid,<br>         * although strange.<br>         */<br>        switch (sock->type) {<br>        case isc_sockettype_tcp:<br>        case isc_sockettype_unix:<br>                if (cc == 0) {<br>                        return (DOIO_EOF);<br>                }<br>                break;<br>        case isc_sockettype_udp:<br>        case isc_sockettype_raw:<br>                break;<br>        default:<br>                INSIST(0);<br>                ISC_UNREACHABLE();<br>        }<br><br>        if (sock->type == isc_sockettype_udp) {<br>                dev->address.length = msghdr.msg_namelen;<br>                if (isc_sockaddr_getport(&dev->address) == 0) {<br>                        if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL)) {<br>                                socket_log(sock, &dev->address, IOEVENT,<br>                                           "dropping source port zero packet");<br>                        }<br>                        return (DOIO_SOFT);<br>                }<br>                /*<br>                 * Simulate a firewall blocking UDP responses bigger than<br>                 * 'maxudp' bytes.<br>                 */<br>                if (sock->manager->maxudp != 0 &&<br>                    cc > (int)sock->manager->maxudp) {<br>                        return (DOIO_SOFT);<br>                }<br>        }<br><br>        socket_log(sock, &dev->address, IOEVENT, "packet received correctly");<br><br><br>I'd rather avoid having to dive deeper in the code to understand what conditions can cause BIND to ignore "packets received correctly" that seems to happen when this socket_log function is called.<br><br>I would appreciate if anybody can help with this or give some hint.<br><br><div>Thank you,</div><br>-- <br><div dir="ltr"><div dir="ltr"><div><div><span style="font-size:12.8px">Bernardo</span></div></div></div></div></div><div id="gmail-m_393155279868745731DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br> <table style="border-top:1px solid rgb(211,212,222)">
        <tbody><tr>
      <td style="width:55px;padding-top:18px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" style="width: 46px; height: 29px;" width="46" height="29"></a></td>
                <td style="width:470px;padding-top:17px;color:rgb(65,66,78);font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Libre de virus. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" style="color:rgb(68,83,234)" target="_blank">www.avast.com</a>          </td>
        </tr>
</tbody></table>
<a href="#m_393155279868745731_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div><span style="font-size:12.8px">Bernardo</span><br></div></div></div></div>