mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-05-15 14:15:52 -06:00
[GH-ISSUE #261] Feature: resolution of mDNS host name (.local) #131
Labels
No labels
Xorg
documentation
enhancement
macos
pull-request
question
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/lan-mouse#131
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @DrYak on GitHub (Feb 12, 2025).
Original GitHub issue: https://github.com/feschber/lan-mouse/issues/261
Would there be an easy way for lan-mouse to resolve mDNS (avahi, etc.) host names so machines can easily find each other on the network?
Request:
Currently, it seems that lan-mouse treats them as a regular host name, adds the DNS domain and performs a normal look-up:
leads to:
Adding a dot at least avoids appending the domain, but still performs normal DNS look-up (which fails):
leads to:
Is there some rust resolver library which could easily abstract that? (e.g.: something like the GNU C Library which uses
/etc/nsswitch.conf)Context:
my university uses horribly arcane automatic naming, based on the abstract connection to the wired 802.1x router to name the machines (today that netbook is
bsse-bs-dock-128-117.ethz.ch.). Finding each-other based on mDNS is much more convenient, but currently I need to copy-paste the output ofavahi-resolve-host-name -n nereid.localinto anip = [ … ]option of the config.toml@feschber commented on GitHub (Feb 12, 2025):
I really don't know too much about mDNS but I guess there is this crate which seems fairly popular: https://crates.io/crates/mdns
I will have to read up on the whole mDNS / avahi stuff though before I do something dumb.
@DrYak commented on GitHub (Feb 18, 2025):
I would say you don't (necessarily⁺) need to handle the whole mDNS support inside lan-mouse yourself.
(i.e.: You don't need to advertise services on the local net and auto-discover other clients and servers -- which is part of the purposes covered by mDNS. See the automatic discovery of stuff like AirPlay, CUPS and AirPrint, DLNA media streaming, etc. E.g. the demo code on that crate tries to auto-discover all Chromcast devices currently on the local network)
Among other you don't need to run your own multicast server to advertise whatever.
What you just need is the "resolve names" part: just being able to find the IP address that corresponds to a
.localdomain.I think this would better cover the needs:
https://crates.io/crates/mdns-resolver
and specially this part:
The demo binary is exactly what lan-mouse would need to do:
https://github.com/timothyb89/mdns-resolver/blob/master/src/bin/mdns-query.rs#L32
I just don't know how good this is as a package. (I'm not fluent in Rust)
⁺ : well, you could go the whole she-bang and implement a full mDNS server, and do automatic service discovery, and allow instances of lan-mouse on the same network to autodiscover each other, and e.g. rely on the encryption key to trust each other and put on the correct border. (i.e.: you completely drop machine names and ip addresses out of the configuration, you just have entries using public key and it's up to the multicast system to find if somewhere on the network there's a machine with authorised matching keys). But that's probably way beyond the scope of lan-mouse 1.0.
@tv42 commented on GitHub (Feb 27, 2025):
.localworked just fine for me. Maybe your system is not configured to resolve.localcorrectly? Tryhost nereid.local, if that doesn't work well...@DrYak commented on GitHub (Jul 25, 2025):
Depends on how you define 'correctly'. In my case, I have setup mdns in
/etc/nsswitch.conf, so software that relies simply on libc for name resolution will successfully resolve the name:BUT
/etc/resolv.confmerely point to the modem/router's internal DNS and that one doesn't resolve mDNS/avahi host names. So software that spefically only talks to DNS servers (like apparently your test, or likedrill/dig) will not resolve those addrress.I know it's possible to use a local DNS resolver (
dnsmasq,systemd-resolved, etc.) that can do a lot more stuff (forward to an external DNS, cache answers, query other sources), it just happens that these specific machines haven't one setup currently.@DrYak commented on GitHub (Jul 25, 2025):
quickly setting up systemd-resolved because it's super trivial:
so yes indeed, the limitations are that
lan-mouseonly ever queries the DNS server, so the only way to get other type to names to resolve is to use a local resolver (dnsmasq, systemd-resolved, etc.) that has been configured to forward.local.domain to mDNS instead of upstream DNS server.@DrYak commented on GitHub (Jul 25, 2025):
Note that as per RFC 6762, the above behaviour violates the Multicast Standard:
BUT some implementations are limited, e.g., libc musl used in Alpine Linux only supports classic DNS name resolution (unlike glibc) and thus needs to rely on tricks such as avahi2dns.
This might be the reason why software like
systemd-resolveddecided to implement mDNS to help such more limited environments. And in turn, given the popularity of that implementation, it might explain why software libraries implement mDNS 'the wrong way around' (by querying DNS instead of directly querying mDNS) because mDNS-enabled sytemd-resolved.conf are widespread.So the fact that it works sometime in lan-mouse is just a happy coincidence of a very widespread hack.