How can I reliably address different machines on my network?
I've always used the .local
suffix to talk to computers on my local network before. With a new router, though, .local
rarely (though sometimes) works. I've found that .home
and .lan
both usually work, but not always.
.-------. .--------. .-----.
| modem |---| router |))))))(wifi))))))| foo |
.-------. .--------. v .-----.
|| | v
/_^_^_\ | \))))))).-----.
/ cloud \ | | bar |
\-_-_-/ .-----. .-----.
| baz |
.-----.
So, from a terminal on foo
, I can try:
ssh bar.local
ssh bar.home
ssh bar.lan
ssh baz.local
ssh baz.home
ssh baz.lan
and sometimes some of those suffixes work and some don't, but I don't know how to predict which or when.
foo
, bar
, and baz
are all modern Linux or Android systems and the Linux boxes all have (or can have) avahi-daemon, or other reasonably-available packages, installed
(I don't want to set up static IP addresses: I'd like to keep using DHCP (from the router) for each machine, and even if I was okay with static addresses I'd want to be able to enter hostnames in the unrooted Android machines, where I can't edit the hosts file to map a chosen hostname to an IP address.)
Best Answer
There are no RFCs that specify
.lan
and.home
. Thus, it is up to the router's vendor what pseudo TLDs (top-level-domain names) are by default configured.For example my router vendor (AVM) seems to use
.fritz.box
by default..local
is used by mDNS (multicast DNS), a protocol engineered by Apple. Usingexample.local
only works on systems (and for destinations) that have a mDNS daemon running (e.g. MacOSX, current Linux distributions like Ubuntu/Fedora).You can keep using dhcp - but perhaps you have to configure your router a little bit. Most routers let you configure such things like the domain name for the network.
Note that using pseudo TLDs is kind of dangerous -
.lan
seems to be popular - and better than.local
(because it does not clash with mDNSs.local
) - but there is no guarantee that ICANN will not introduce it as new TLD at some point.2019 update: Case in point,
.box
isn't a pseudo TLD, anymore. ICANN delegated .box in 2016.Thus, it makes sense to get a real domain name - and use sub-domains of it for private stuff, e.g. when your domain is
example.org
you could use: