<p>I have a K8S 1.14 cluster setup with CoreDNS 1.5.0 as default DNS server. My ubuntu 14.04 client failed to resolve service name when I got a response with TTL less than the minimun TTL value in SOA field(response with IPv6 result, no IPv6 address resolved). </p>

<p>I tried to use the same client code in Ubuntu 18.04 which can resolve the service name every time. I'm using python socket.getaddrinfo to resolve the service name, using socket.gethostbyname works around this issue since it only queries the A records.</p>

<p>This is the code i used to test</p>

<pre class="lang-py prettyprint-override"><code>import socket
import time

while True:
    try:
        time.sleep(2)
        print socket.getaddrinfo("kubernetes", "443")
    except Exception as e:
        print e
</code></pre>

<p>The result of running this code is as followed:</p>

<p>[(2, 1, 6, '', ('10.233.0.1', 443)), (2, 2, 17, '', ('10.233.0.1', 443)), (2, 3, 0, '', ('10.233.0.1', 443))]</p>

<p>[Errno -5] No address associated with hostname</p>

<p>[Errno -5] No address associated with hostname</p>

<p>[(2, 1, 6, '', ('10.233.0.1', 443)), (2, 2, 17, '', ('10.233.0.1', 443)), (2, 3, 0, '', ('10.233.0.1', 443))]</p>

<p>[Errno -5] No address associated with hostname</p>

<p>[Errno -5] No address associated with hostname</p>

<p>When i update the default ttl to 30 seconds, I got more failures util I got the response with TTL 30</p>

Hang Du
<p>It seems this problem is related to <strong>dns caching</strong>.</p>
<p>Before dns caching was enabled in ubuntu 14:04:</p>
<pre><code>[(2, 1, 6, '', ('10.96.0.1', 443)), (2, 2, 17, '', ('10.96.0.1', 443)), (2, 3, 0, '', ('10.96.0.1', 443))]
[Errno -5] No address associated with hostname
[Errno -5] No address associated with hostname
[Errno -5] No address associated with hostname
</code></pre>
<p>After dns caching installation f.e. <a href="http://manpages.ubuntu.com/manpages/bionic/man8/nscd.8.html" rel="nofollow noreferrer">nscd</a>:</p>
<pre><code>apt-get install nscd
service nscd start

[(2, 1, 6, '', ('10.96.0.1', 443)), (2, 2, 17, '', ('10.96.0.1', 443)), (2, 3, 0, '', ('10.96.0.1', 443))]
[(2, 1, 6, '', ('10.96.0.1', 443)), (2, 2, 17, '', ('10.96.0.1', 443)), (2, 3, 0, '', ('10.96.0.1', 443))]
[(2, 1, 6, '', ('10.96.0.1', 443)), (2, 2, 17, '', ('10.96.0.1', 443)), (2, 3, 0, '', ('10.96.0.1', 443))]
[(2, 1, 6, '', ('10.96.0.1', 443)), (2, 2, 17, '', ('10.96.0.1', 443)), (2, 3, 0, '', ('10.96.0.1', 443))]
[(2, 1, 6, '', ('10.96.0.1', 443)), (2, 2, 17, '', ('10.96.0.1', 443)), (2, 3, 0, '', ('10.96.0.1', 443))]
</code></pre>
<p>You can verify your dns caching in /etc/nscd.conf</p>
<p>If i am correct - DNS isn't cached in Ubuntu &lt; 17.04</p>
<p>In addition - according to official release timeline for ubuntu 14.04.6: <em>End of Standard Support is April 2019</em>
Hope this help.</p>
