<div dir="ltr">Hi All,<div><br></div><div><div style="font-size:12.8px">I am struggling with a specific use case of dnsmasq, involving localised DNS caches on servers, and was hoping for some external input.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">We use a service discovery subsystem known as Consul (<a href="https://consul.io/" target="_blank">https://consul.io/</a>), which provides a DNS interface (<a href="https://consul.io/docs/agent/dns.html" target="_blank">https://consul.io/docs/agent/dns.html</a>) to find other servers on our network. There is no DNS caching functionality within Consul that I can tell.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">We have dnsmasq installed on local machines, with upstream resolvers (ISP/Google etc) and resolv.conf pointing at 127.0.0.1, this provides us with local DNS caching for general Internet DNS resolution.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">In addition, we have a config entry that looks like this:</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">server=/consul/<a href="http://172.17.42.1/#8600" target="_blank">172.17.42.1#8600</a></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">This sends all requests for *.consul to the nameserver 172.17.42.1 (docker0 interface), on UDP 8600, which resides on the local machine.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">These requests are being responded to correctly, and we have Consul configured to return a max 3 second TTL on result sets (standard A records in this case). For some reason though, dnsmasq is not caching this and decrementing the TTL on subsequent requests for the same hostname, it is instead re-requesting a result from Consul.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">One interesting find, the responses from dnsmasq appear with the "aa" flag, denoting an authoritative answer. Does this imply that dnsmasq believes it is authoritative for the results via this nameserver, as opposed to just acting as a recursor?</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Is there an additional configuration option we need to set at all to make dnsmasq appear as a caching recursive resolver only here?</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Tested on dnsmasq versions 2.68 (Ubuntu 14.04.2 packages) and 2.75 built from source.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><span style="font-size:12.8px">See below our config and some example queries, relevant lines of interest in bold:</span><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">-----------------------------------------------<br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><b>dnsmasq.conf</b></div><div style="font-size:12.8px"><br></div><div style=""><div style=""><span style="font-size:12.8px">no-hosts</span></div><div style=""><span style="font-size:12.8px">strict-order</span></div><div style=""><span style="font-size:12.8px">cache-size=5000</span></div><div style=""><span style="font-size:12.8px">no-resolv</span></div><div style=""><span style="font-size:12.8px">no-poll</span></div><div style=""><span style="font-size:12.8px">bind-interfaces</span></div><div style=""><br></div><div style=""><span style="font-size:12.8px">interface=lo</span></div><div style=""><span style="font-size:12.8px">no-dhcp-interface=lo</span></div><div style=""><span style="font-size:12.8px">interface=docker0</span></div><div style=""><span style="font-size:12.8px">no-dhcp-interface=docker0</span></div><div style=""><br></div><div style=""><span style="font-size:12.8px">server=/consul/<a href="http://172.17.42.1#8600">172.17.42.1#8600</a></span></div><div style=""><br></div><div style=""><span style="font-size:12.8px">server=8.8.8.8</span></div><div style=""><span style="font-size:12.8px">server=8.8.4.4</span></div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><b>Query to upstream server direct:</b></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><div>root@ip-10-201-0-230:~# dig @<a href="http://172.17.42.1/" target="_blank">172.17.42.1</a> d8607ce495db.node.aws-us-east-1.consul</div><div><br></div><div>; <<>> DiG 9.9.5-3ubuntu0.5-Ubuntu <<>> @<a href="http://172.17.42.1/" target="_blank">172.17.42.1</a> d8607ce495db.node.aws-us-east-1.consul</div><div>; (1 server found)</div><div>;; global options: +cmd</div><div>;; Got answer:</div><div>;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25786</div><div>;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0</div><div><br></div><div>;; QUESTION SECTION:</div><div>;d8607ce495db.node.aws-us-east-1.consul.<span style="white-space:pre-wrap">      </span>IN A</div><div><br></div><div>;; ANSWER SECTION:</div><div><b>d8607ce495db.node.aws-us-east-1.consul.<span style="white-space:pre-wrap">   </span>3 IN A<span style="white-space:pre-wrap">  </span>10.20.0.230</b></div><div><br></div><div>;; Query time: 3 msec</div><div>;; SERVER: 172.17.42.1#53(172.17.42.1)</div><div>;; WHEN: Thu Oct 01 05:01:21 UTC 2015</div><div>;; MSG SIZE  rcvd: 110</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">-----------------------------------------------</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><b>Multiple queries against local dnsmasq in short succession, expecting a decrementing TTL (starting at 3 seconds):</b></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><div>root@ip-10-201-0-230:~# date; dig d8607ce495db.node.aws-us-east-1.consul</div><div><b>Thu Oct  1 05:01:54 UTC 2015</b></div><div><br></div><div>; <<>> DiG 9.9.5-3ubuntu0.5-Ubuntu <<>> d8607ce495db.node.aws-us-east-1.consul</div><div>;; global options: +cmd</div><div>;; Got answer:</div><div>;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45386</div><div>;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0</div><div><br></div><div>;; QUESTION SECTION:</div><div>;d8607ce495db.node.aws-us-east-1.consul.<span style="white-space:pre-wrap">      </span>IN A</div><div><br></div><div>;; ANSWER SECTION:</div><div><b>d8607ce495db.node.aws-us-east-1.consul.<span style="white-space:pre-wrap">   </span>3 IN A<span style="white-space:pre-wrap">  </span>10.20.0.230</b></div><div><br></div><div>;; Query time: 2 msec</div><div>;; SERVER: 127.0.0.1#53(127.0.0.1)</div><div>;; WHEN: Thu Oct 01 05:01:54 UTC 2015</div><div>;; MSG SIZE  rcvd: 110</div><div><br></div><div>root@ip-10-201-0-230:~# date; dig d8607ce495db.node.aws-us-east-1.consul</div><div><b>Thu Oct  1 05:01:55 UTC 2015</b></div><div><br></div><div>; <<>> DiG 9.9.5-3ubuntu0.5-Ubuntu <<>> d8607ce495db.node.aws-us-east-1.consul</div><div>;; global options: +cmd</div><div>;; Got answer:</div><div>;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30672</div><div>;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0</div><div><br></div><div>;; QUESTION SECTION:</div><div>;d8607ce495db.node.aws-us-east-1.consul.<span style="white-space:pre-wrap">      </span>IN A</div><div><br></div><div>;; ANSWER SECTION:</div><div><b>d8607ce495db.node.aws-us-east-1.consul.<span style="white-space:pre-wrap">   </span>3 IN A<span style="white-space:pre-wrap">  </span>10.20.0.230</b></div><div><br></div><div>;; Query time: 2 msec</div><div>;; SERVER: 127.0.0.1#53(127.0.0.1)</div><div>;; WHEN: Thu Oct 01 05:01:55 UTC 2015</div><div>;; MSG SIZE  rcvd: 110</div><div><br></div><div>root@ip-10-201-0-230:~# date; dig d8607ce495db.node.aws-us-east-1.consul</div><div><b>Thu Oct  1 05:01:55 UTC 2015</b></div><div><br></div><div>; <<>> DiG 9.9.5-3ubuntu0.5-Ubuntu <<>> d8607ce495db.node.aws-us-east-1.consul</div><div>;; global options: +cmd</div><div>;; Got answer:</div><div>;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4229</div><div>;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0</div><div><br></div><div>;; QUESTION SECTION:</div><div>;d8607ce495db.node.aws-us-east-1.consul.<span style="white-space:pre-wrap">       </span>IN A</div><div><br></div><div>;; ANSWER SECTION:</div><div><b>d8607ce495db.node.aws-us-east-1.consul.<span style="white-space:pre-wrap">   </span>3 IN A<span style="white-space:pre-wrap">  </span>10.20.0.230</b></div><div><br></div><div>;; Query time: 2 msec</div><div>;; SERVER: 127.0.0.1#53(127.0.0.1)</div><div>;; WHEN: Thu Oct 01 05:01:55 UTC 2015</div><div>;; MSG SIZE  rcvd: 110</div><div><br></div><div>Regards,</div><div><br></div><div>Nathan Sullivan.</div></div></div></div>