Remix.run Logo
▲ wolrah 3 days ago

> I was answering the question of “how do I discover another host’s mDNS hostname?” It turns out that is a per-service question.

No, it's not. That is a service address, not the host's hostname.

The host's hostname is whatever the computer is named, which if you are in a position where you're wanting to give someone else its IPv4 address or access your own thing via its IPv4 address you definitely can also know it's hostname because it's either shown in the same parts of the GUI or one command away. On a lot of CLI systems it's literally in the prompt.

Either way it's not advertised unless that host is configured to advertise itself, you have to query for it and the host will then respond.

▲mahboi 3 days ago | parent [-]

Not every host lets you SSH into it to run commands. The mDNS hostname is not always the same as your system hostname since it can change due to conflicts. Some Linux distros don't even have a built-in util to show your own mDNS name.

▲wolrah 2 days ago | parent [-]

> Not every host lets you SSH into it to run commands.

Not sure how this is relevant. The context we're talking about here is someone wanting to communicate to another person how to connect to their laptop. We can assume that this person has sufficient access to the device to get this information.

You're not trying to work backwards from an unknown device here, if you're doing that you presumably have the ability to copy/paste the full address from whatever tool you used to identify the device's existence on the network.

> The mDNS hostname is not always the same as your system hostname since it can change due to conflicts.

And it changes in predictable ways, with the mainstream desktop OSes presenting a notification to the user in case of conflicts. If yours doesn't, consider that a flaw in your OS.

Also, if this is a real issue you run in to more than once in a blue moon it's probably worth picking a more unique name.

> Some Linux distros don't even have a built-in util to show your own mDNS name.

systemctl status avahi-daemon

should do the trick on any mainstream Linux distro, and if you're one of the anti-systemd crowd you presumably know your equivalent.

▲mahboi 12 hours ago | parent | next [-]

Ok, guess it's on me for giving an example where the host is a PC where I have access, but it very well might not be.

▲ 2 days ago | parent | prev [-]
[deleted]