{"id":622,"date":"2018-12-08T07:44:53","date_gmt":"2018-12-08T15:44:53","guid":{"rendered":"https:\/\/porkrind.org\/missives\/?p=622"},"modified":"2019-02-17T21:07:32","modified_gmt":"2019-02-18T05:07:32","slug":"att-causes-mdns-on-linux-to-fail","status":"publish","type":"post","link":"https:\/\/porkrind.org\/missives\/att-causes-mdns-on-linux-to-fail\/","title":{"rendered":"AT&#038;T causes mDNS on Linux To Fail"},"content":{"rendered":"<p>Today my Jenkins builds were not working because all of the build slaves were offline. Digging around in the logs showed that the couldn&#8217;t connect because of name resolution failures. I use mDNS on my network (the slaves are Mac OS X VMs running on a Mac Mini), and so they were named something like <code>xxxx-1.local<\/code> and <code>xxxx-2.local<\/code> I tried just pinging the machines and that refused to resolve the name, too.<\/p>\n<p>I verified that Avahi was running, and then used <code>avahi-resolve --name xxxx-1.local<\/code> to check the mDNS name resolution. It worked just great.<\/p>\n<p>So why would mDNS be working fine network-wise, but no programs were resolving correctly? It struck me that I didn&#8217;t know (or couldn&#8217;t remember!) how mDNS tied in to the system. Who hooks in to the name resolution and knows to check for <code>*.local<\/code> using mdns?<\/p>\n<p>It turns out it&#8217;s good old <code>\/etc\/nsswitch.conf<\/code> (I should have remembered that)! There&#8217;s a line in there:<\/p>\n<pre><code>hosts:          files mdns4_minimal [NOTFOUND=return] dns\n<\/code><\/pre>\n<p>That tells the libc resolver (that everything uses) that when it&#8217;s looking for a hostname, it should first look in the <code>\/etc\/hosts<\/code> file, then it should check mDNS, then if mDNS didn&#8217;t handle it, check regular DNS. Wait, so mDNS is built right in to libc??<\/p>\n<p>Nope! On my Debian system there&#8217;s a package called <code>libnss-mdns<\/code> that has a few files in it:<\/p>\n<pre><code>\/lib\/x86_64-linux-gnu\/libnss_mdns.so.2\n\/lib\/x86_64-linux-gnu\/libnss_mdns4.so.2\n\/lib\/x86_64-linux-gnu\/libnss_mdns4_minimal.so.2\n\/lib\/x86_64-linux-gnu\/libnss_mdns6.so.2\n\/lib\/x86_64-linux-gnu\/libnss_mdns6_minimal.so.2\n\/lib\/x86_64-linux-gnu\/libnss_mdns_minimal.so.2\n<\/code><\/pre>\n<p>Those are plugins to the libc name resolver so that random stuff like mDNS doesn&#8217;t have to be compiled into libc all the time. In fact, there&#8217;s a whole bunch of other libnss plugins in Debian that I don&#8217;t even have installed.<\/p>\n<p>So my guess was that this nss-mdns plugin was causing the problem. There are no man pages in the package, but there are a couple README files. I poked around trying random things and reading and re-reading the READMEs many times before this snippet finally caught my eye:<\/p>\n<blockquote><p>\n  If, during a request, the system-configured unicast DNS (specified in <code>\/etc\/resolv.conf<\/code>) reports an <code>SOA<\/code> record for the top-level <code>local<\/code> name, the request is rejected. Example: <code>host -t SOA local<\/code> returns something other than <code>Host local not found: 3(NXDOMAIN)<\/code>.\u00a0 <em>This is the unicast SOA heuristic.<\/em>\n<\/p><\/blockquote>\n<p>Ok. I doubted that was happening but I decided to try their test anyway:<\/p>\n<pre><code>$ host -t SOA local\nlocal. has SOA record ns1-etm.att.net. nomail.etm.att.net. 1 604800 3600 2419200 900\n<\/code><\/pre>\n<p>Crap.<\/p>\n<p>Those bastards at AT&amp;T set their DNS server up to hijack unknown domains! They happily give out an <code>SOA<\/code> for the non-existant <code>.local<\/code> TLD. So AT&amp;T&#8217;s crappy DNS is killing my Jenkins jobs??? Grrrrr\u2026<\/p>\n<p>The worst part is that I <em>tried<\/em> to use Cloudflare&#8217;s <code>1.0.0.1<\/code> DNS. My router was configured for it. But two things happened: 1. I got a new modem after having connection issues recently, 2. I enabled IPv6 on my router for fun. The new modem seems to have killed <code>1.0.0.1<\/code>. I can no longer connect to it at all. Enabling IPv6 gave me an AT&amp;T DNS server through DHCP (or whatever the IPv6 equivalent is).<\/p>\n<p>So, straightening out my DNS (I had to revert back to Google&#8217;s <code>8.8.8.8<\/code>) caused <code>NXDOMAIN<\/code> responses to the <code>.local<\/code> <code>SOA<\/code>, and that caused mDNS resolution to immediately work, and my Jenkins slaves came back online. Fwew.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today my Jenkins builds were not working because all of the build slaves were offline. Digging around in the logs showed that the couldn&#8217;t connect because of name resolution failures. I use mDNS on my network (the slaves are Mac OS X VMs running on a Mac Mini), and so they were named something like &hellip; <a href=\"https:\/\/porkrind.org\/missives\/att-causes-mdns-on-linux-to-fail\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">AT&#038;T causes mDNS on Linux To Fail<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-622","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/posts\/622","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/comments?post=622"}],"version-history":[{"count":10,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/posts\/622\/revisions"}],"predecessor-version":[{"id":644,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/posts\/622\/revisions\/644"}],"wp:attachment":[{"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/media?parent=622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/categories?post=622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/tags?post=622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}