<p>Our JVM services (based on Java SE 8/Scala/Finagle) have problems resolving DNS names. I have checked <code>coredns</code> deployment logs in <code>kube-system</code> namespace and found out that <code>java.net.InetAddress.getAllByName()</code> is querying for <code>ANY</code> record type.</p>
<p>If I check name resolution via <code>nslookup</code> I can confirm that <code>ANY</code> record type is not resolvable, but <code>A</code> or <code>AAAA</code> records are:</p>
<pre><code># kubectl exec -i -t dnsutils -- nslookup -type=a weather.mab.matjazmav.test
Server:         10.96.0.10
Address:        10.96.0.10#53

Name:   dev-proxy.default.svc.cluster.local
Address: 10.100.187.185

# kubectl exec -i -t dnsutils -- nslookup -type=any weather.mab.matjazmav.test
Server:         10.96.0.10
Address:        10.96.0.10#53

*** Can't find weather.mab.matjazmav.test: No answer
</code></pre>
<p>My question is, how can I make Minikube's CoreDNS respond to <code>ANY</code> query, or how can I force <code>java.net.InetAddress</code> to send <code>A</code> or <code>AAAA</code> query?</p>
<p><strong>EDIT:</strong>
It turned out that we used old NS provider that ships with Java SE 8 (<code>sun.net.spi.nameservice.provider.1=dns,sun</code>) see my answer for details.</p>

Matjaž
<p>I found two possible solutions:</p>
<p><strong>1. Use CoreDNS rewrite plugin</strong></p>
<p>Rewrite query types from <code>ANY</code> to <code>A</code>. Here is a link to the documentation: <a href="https://coredns.io/plugins/rewrite/" rel="nofollow noreferrer">https://coredns.io/plugins/rewrite/</a></p>
<p><strong>2. Use default NS provider inside JVM</strong></p>
<p>This applies only if you run on Jave SE 8 or older. <strong>Java SE 9 removed this system property</strong>, read more here: <a href="https://www.oracle.com/java/technologies/javase/9-removed-features.html#JDK-8134577" rel="nofollow noreferrer">https://www.oracle.com/java/technologies/javase/9-removed-features.html#JDK-8134577</a></p>
<p>Java SE 8 ships with two NS providers <code>default</code> and <code>dns,sun</code>. <code>default</code> provider  uses system's NS provider while <code>dns,sun</code> uses some old NS implementation.</p>
<p>To use <code>default</code> NS provider simply set the following property:</p>
<pre><code>sun.net.spi.nameservice.provider.1=default
</code></pre>
<p>Read more here: <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/net/properties.html" rel="nofollow noreferrer">https://docs.oracle.com/javase/8/docs/technotes/guides/net/properties.html</a></p>
<p>Also this is a nice read: <a href="https://medium.com/@maheshsenni/host-name-resolution-in-java-80301fea465a" rel="nofollow noreferrer">https://medium.com/@maheshsenni/host-name-resolution-in-java-80301fea465a</a></p>
