{"id":1035,"date":"2014-12-17T08:36:49","date_gmt":"2014-12-17T15:36:49","guid":{"rendered":"http:\/\/jaredrobinson.com\/blog\/?p=1035"},"modified":"2014-12-17T08:36:49","modified_gmt":"2014-12-17T15:36:49","slug":"ubuntu-and-local-hostnames-in-a-corporate-network","status":"publish","type":"post","link":"https:\/\/jaredrobinson.com\/blog\/ubuntu-and-local-hostnames-in-a-corporate-network\/","title":{"rendered":"Ubuntu and .local hostnames in a corporate network"},"content":{"rendered":"<p>In the past, I&#8217;ve had trouble getting my Ubuntu machine to resolve the .local hostnames at work. I didn&#8217;t know why Ubuntu had this problem while other machines did not.<\/p>\n<p>When I did a DNS lookup, it failed, and ping of host.something.local failed. Yet ping of the hostname without the .something.local extension worked. Odd. I googled various terms, but nothing useful came up. I tried watching the DNS lookup with tcpdump, but it didn&#8217;t capture anything.<\/p>\n<p>Eventually, I thought of using &#8216;strace ping host.something.local&#8217; to see what was happening, and it turns out that DNS was never being queried &#8212; it was talking to something called avahi.<\/p>\n<p>I googled &#8220;avahi&#8221;, and was reminded that hostname resolution is configured in \/etc\/nsswitch.conf. In the case of Ubuntu, it&#8217;s configured to send *.local requests to Avahi (mdns4_minimal), and no further &#8212; i.e. if Avahi doesn&#8217;t resolve it, it doesn&#8217;t try DNS.<\/p>\n<p>In my case, I want corporate DNS to resolve .local addresses. So I changed my \/etc\/nsswitch.conf from this:<\/p>\n<p>    hosts:          files mdns4_minimal [NOTFOUND=return] wins dns mdns4<\/p>\n<p>to this:<\/p>\n<p>    hosts:          files wins dns mdns4_minimal mdns4<\/p>\n<p>And now my Ubuntu development machine can communicate with our internal .local machines without having to resort to using IP addresses, short names, or having to place the mapping in \/etc\/hosts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the past, I&#8217;ve had trouble getting my Ubuntu machine to resolve the .local hostnames at work. I didn&#8217;t know why Ubuntu had this problem while other machines did not. When I did a DNS lookup, it failed, and ping of host.something.local failed. Yet ping of the hostname without the .something.local extension worked. Odd. I &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/jaredrobinson.com\/blog\/ubuntu-and-local-hostnames-in-a-corporate-network\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Ubuntu and .local hostnames in a corporate network&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,17],"tags":[],"class_list":["post-1035","post","type-post","status-publish","format-standard","hentry","category-linux","category-tech"],"_links":{"self":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts\/1035","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/comments?post=1035"}],"version-history":[{"count":4,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts\/1035\/revisions"}],"predecessor-version":[{"id":1040,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts\/1035\/revisions\/1040"}],"wp:attachment":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/media?parent=1035"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/categories?post=1035"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/tags?post=1035"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}