by mahboi · 3w ago · 0 comments
~ $ arp -a
? (192.168.50.1) at e8:9c:25:52:83:10 on en0 ifscope [ethernet]
? (192.168.50.9) at 64:9a:63:eb:ed:f1 on en0 ifscope [ethernet]
? (192.168.50.50) at 14:98:77:70:17:a7 on en0 ifscope [ethernet]AFAIK you must always specify a service like `_ssh._tcp` or `_http._tcp`; you can’t ask dns-sd to just dump all the advertised mDNS services on your network. That might be possible with the underlying `nw_browser_t` APIs, though.
"you can’t ask dns-sd to just dump all the advertised mDNS services on your network": I ran into this too. So besides the defaults and maybe network itself standing in the way, the tooling around mDNS is user-unfriendly.
For address discovery which is what we're really talking about here it's just "<hostname>.local"
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.
Here's me pinging my laptop (macOS 27) from my file server (Ubuntu 24.04)
~ ping persephone.local
PING persephone.local (fd82:74ca:1cef:385a:1897:2e4b:a726:18b6%3) 56 data bytes
64 bytes from fd82:74ca:1cef:385a:1897:2e4b:a726:18b6: icmp_seq=1 ttl=64 time=0.496 ms
64 bytes from fd82:74ca:1cef:385a:1897:2e4b:a726:18b6: icmp_seq=2 ttl=64 time=0.515 ms
^C
--- persephone.local ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.496/0.505/0.515/0.009 msWe're talking about somebody who knows how to get the IPv4 address of their computer, the hostname is available in basically the same exact place on every single system, and easier to remember, and remains the same on every network unless there's a conflict.
It works as long as the network operator of system admin hasn't gone out of their way to break it.
> Shouldn't those question marks be the hostnames on arp -a? On some networks it shows them, on others it doesn't.
Those question marks will fill in if there is a reverse dns entry in the local DNS server, which is set in IPv4 networks based on the device putting its hostname in the DHCP request. Most consumer combo gateway devices will do this by default as does Windows DHCP, but a lot of business firewall devices don't do it at all or don't do it by default.
Either way, that's not relevant to IPv6, mDNS is the way.
I'm pretty frequently in a scenario where I know local v4 addrs but not hostnames, usually on a network that's not my own. But even on my own network cause there's no simple way to discover the names, so not everything is a Linux box I can SSH into to ask the hostname. I'd use mDNS if I could reliably type something in to show all the DNS entries on the LAN, never having to diagnose any issues with this.