Resolve .local hosts

Connection sharing, Firewall, Samba..etc
Forum rules
Before you post please read how to get help
Post Reply
User avatar
matm
Level 1
Level 1
Posts: 31
Joined: Sun Apr 22, 2012 5:12 pm

Resolve .local hosts

Post by matm »

Hello

I'm on my local network.
I have a host named turtle with an avahi daemon, so ping turtle.local works fine (and ssh, and port 80, for the record).

I tried to configure name resolution on my Linux Mint 19 box so I can do ping turtle.
I have updated /etc/systemd/resolved.conf with Domains=local, as stated by the man. I restarted, checked that /etc/resolv.conf looks ok (search local is here).
But ping turtle still doesn't work.

I can't see what's wrong. Any help welcome.

Regards

Mat
Cooler Master Sileo 500 ¤ Corsair TX - 650 ¤ Asus P7P55 ¤ Core i5-750 ¤ 2x4GB G-Skill RipJaws-X ¤ Sapphire VaporX ATI HD5850 ¤ SSD Samsung 830 128GB + Evo840 256GB
rene
Level 16
Level 16
Posts: 6673
Joined: Sun Mar 27, 2016 6:58 pm

Re: Resolve .local hosts

Post by rene »

.local names are resolved not through DNS and normally long before DNS, hence long before /etc/resolv.conf is ever consulted. That is...

"Normal" name resolving (i.e., through the regular system libraries) is configured through /etc/nssswitch.conf. If you look you will see something like

Code: Select all

hosts:          files mdns4_minimal [NOTFOUND=return] wins dns myhostname
and any of those entries refer to a fully different type of resolver. .local is mDNS and is as you can see resolved early on, directly after and if "files" (i.e., /etc/hosts) failed to resolve a certain name (the [NOTFOUND=return] interjection has resolving of .local names not resolved by mDNS fail at that point; not try further i.e., has mDNS authoratitive for .local, so to speak).

In any case, what's important here is that "dns" is later: when you try to resolve "turtle" it fails to be resolved by /etc/hosts, then via mDNS, then (in this case) WINS and only then gets to DNS. Also fails that, retries as "turtle.local" -- but also fails, first probably because it knows to not even try .local names but certainly also because we're long past mDNS which is the only thing that resolves turtle.local.

Or, well, that's to say...

systemd-resolved can actually be configured to do mDNS itself at which point .local as a search domain might be functional. I don't use systemd-resolved (have replaced it with dnsmasq) and can as such not in fact test things but for this you certainly need MulticastDNS=true or MulticastDNS=resolve in /etc/systemd/resolved.conf and I believe sudo systemd-resolve --set-mdns=yes --interface=<interface> for the correct interface (enp<X>s<Y> or some such).

I could not tell you if you should in this situation also keep Avahi up or whether or not this would create conflicts; can as said not easily test things locally. The best answer in any case is that you should just spell out the .local suffix if using mDNS...
User avatar
Kadaitcha Man
Level 11
Level 11
Posts: 3891
Joined: Mon Aug 27, 2012 10:17 pm

Re: Resolve .local hosts

Post by Kadaitcha Man »

matm wrote:
Thu Apr 09, 2020 5:36 pm
I can't see what's wrong.
That's because you're trying to configure a highly complex feature without understanding all the ins and outs of what you must do to get it working.

I had started to explain what you need to do but it was turning into the Epic of Gilgamesh. It's going to be far simpler to switch your internal network over to static IP, if it isn't already, and put the host names and their IP addresses into /etc/hosts.
It's pronounced kad-eye-cha, not kada-itcha.
User avatar
Kadaitcha Man
Level 11
Level 11
Posts: 3891
Joined: Mon Aug 27, 2012 10:17 pm

Re: Resolve .local hosts

Post by Kadaitcha Man »

rene wrote:
Thu Apr 09, 2020 6:21 pm
I could not tell you if you should in this situation also keep Avahi up or whether or not this would create conflicts;
I haven't used the setup you describe for some time, now preferring a simple hostname and static IP address in /etc/hosts, but, IIRC, the avahi daemon needs to be uninstalled. I think that the poster may be at risk of clobbering his network completely so I've avoided this approach.
It's pronounced kad-eye-cha, not kada-itcha.
rene
Level 16
Level 16
Posts: 6673
Joined: Sun Mar 27, 2016 6:58 pm

Re: Resolve .local hosts

Post by rene »

Whether or not reverting to static configuration is in fact easier than just spelling out turtle.local would remain to be seen, and be a function of the number of systems on your LAN as to syncing copies of /etc/hosts, but for what it's worth, with Avahi hence .local resolution bombing out on some systems after some time, using "static IP" is exactly what I have done also -- although not so much "static IP" in the old sense rather than "steady IP" in the sense of my router handing out the same IP to the same MAC.

mDNS is great in theory; a PoS in practice...
User avatar
Kadaitcha Man
Level 11
Level 11
Posts: 3891
Joined: Mon Aug 27, 2012 10:17 pm

Re: Resolve .local hosts

Post by Kadaitcha Man »

rene wrote:
Thu Apr 09, 2020 6:39 pm
mDNS is great in theory; a PoS in practice...
I couldn't agree more.
It's pronounced kad-eye-cha, not kada-itcha.
User avatar
matm
Level 1
Level 1
Posts: 31
Joined: Sun Apr 22, 2012 5:12 pm

Re: Resolve .local hosts

Post by matm »

Hello,

Thank you rene for the detailed explanation and guidance.
Kadaitcha Man, you're right, I don't know where I go. But still, I started :).

As a summary, it is not doable easily because subdomain search is done at DNS step, and mDNS can't be included there.

Moreover, it looks like the specs of mDNS, is to lookup names ONLY if they end with .local, which implies I can't succeed. If I want short names, I need a local dns server coupled with the DHCP one.

Thank you again for your time. I will cope with .local for now. When I'll be upset enough, I may setup a DNS server :wink:

FTR, the turtle has a steady IP, but I still better remember its name rather than its IP@
Cooler Master Sileo 500 ¤ Corsair TX - 650 ¤ Asus P7P55 ¤ Core i5-750 ¤ 2x4GB G-Skill RipJaws-X ¤ Sapphire VaporX ATI HD5850 ¤ SSD Samsung 830 128GB + Evo840 256GB
rene
Level 16
Level 16
Posts: 6673
Joined: Sun Mar 27, 2016 6:58 pm

Re: Resolve .local hosts

Post by rene »

Not completely correctly summarised; i.e., note the bit about systemd-resolved being able to do mDNS rather than just normal DNS itself as well, at which point a .local search domain might in fact work. But, yes, unsure, bit custom, and more importantly:
matm wrote:
Fri Apr 10, 2020 6:37 pm
FTR, the turtle has a steady IP, but I still better remember its name rather than its IP@
If it in fact has a "steady IP" in the sense of an unchanging one due to e.g. your router having a MAC-based reservation for it or even a true "static IP", say 192.168.123.123, then you can just add

Code: Select all

192.168.123.123	turtle
to /etc/hosts on the system(s) on which you want to access it by name from. I.e., recall that first "files" entry from /etc/nsswitch.conf.
User avatar
matm
Level 1
Level 1
Posts: 31
Joined: Sun Apr 22, 2012 5:12 pm

Re: Resolve .local hosts

Post by matm »

@rene :

Yes, I agree about the resolved-mDNS configuration. I may dive into it one day to have the same (corrupt ?) simplified behaviour as in Windows, where I can reach turtle with ping turtle and give its full name as turtle.local. But Since mDNS has its specs, the issue is still conditional and too big a change to deserve it right now. I need to grow my bitterness first :D

Yes, it has a reserved IP on the router provided by my box. But /etc/hosts would fail when the IP change (box renewal, whatever happens)... Better try resolved to do mDNS.
Cooler Master Sileo 500 ¤ Corsair TX - 650 ¤ Asus P7P55 ¤ Core i5-750 ¤ 2x4GB G-Skill RipJaws-X ¤ Sapphire VaporX ATI HD5850 ¤ SSD Samsung 830 128GB + Evo840 256GB
Post Reply

Return to “Other networking topics”