Assume I have two computers with hostnames pc1 and pc2 in my local network 10.0.0.0/24. My router has the ip address 10.0.0.138 and its instructions say that it is also reachable at modem.home, which I tried and is true.
I want to connect from pc1 to pc2 via ssh and use its hostname, not its ip for that. However, the host commando under linux gives me this result when using the ip address of pc2:
host 10.0.0.53
Host 53.0.0.10.in-addr.arpa not found: 2(SERVFAIL)I tried to do some research about what this means, and I think it says that
Now to my questions:
- What exactly is the
.homedomain? Is it usual or is it just something my router sets up? - How can I add my (linux) computers to that domain so that I can retrieve the hostnames of the other devices (in the local network)?
3 Answers
What exactly is the .home domain? Is it usual or is it just something my router sets up?
It's just something your router sets up.
As many routers do, it internally runs a DNS cache/proxy and advertises itself as the DNS server in all DHCP responses. The router's DNS proxy is configured to serve *.home names out of local configuration instead of forwarding the queries to ISP's DNS. (You can find this feature in dnsmasq if you plan on making your own.)
The router has the name modem.home statically defined to always return its own IP, but other *.home subdomains are usually read from the DHCP server's lease database.
How can I add my (linux) computers to that domain so that I can retrieve the hostnames of the other devices (in the local network)?
Make sure your computers use DHCP and that their DHCP clients always fill in the 'Host name' option (12) in requests. For example, if the computer uses dhclient, add send host-name = gethostname(); to its configuration.
For two computers, you do not need a Domain in my opinion. Set up the Name of the other computer in your local HOSTS file. Do this for each computer. Then you can address the computers by name.
Local hosts file is here:
2What exactly is the
.homedomain? Is it usual or is it just something my router sets up?
While .homes and .home.arpa are defined for specific uses, the .home domain doesn't appear to be at this time (as far as I am aware). That said, the RFC for .home.arpa notes:
The Home Networking Control Protocol (HNCP) is updated to use the 'home.arpa.' domain instead of '.home'.
So it seems there could be some chance .home in this case may have been intended for use with HNCP capable devices for e.g. automatic discovery, configuration, etc. But that is just speculation.
How can I add my (Linux) computers to that domain so that I can retrieve the hostnames of the other devices (in the local network)?
You may want to check your router settings to see if it has any option to add additional hostname and IPs for local resolution.
Otherwise, as detailed in another answer to this question, the simplest method would be to use the hosts file on each PC to define hostname/IP address mappings:
ex. hosts (PC 1 → 10.0.0.10)
10.0.0.20 pc2.homeex. hosts (PC 2 → 10.0.0.20)
10.0.0.10 pc1.homeThe hosts file is generally found under /etc/hosts in Linux/MacOS and C:\windows\system32\drivers\etc\hosts on Windows.
Note that if you have trouble using your hosts file on Linux, you may need to edit /etc/nsswitch.conf and make certain the files entry is listed first under hosts:.
Other Options
Local DNS Server
Without knowing all the details regarding your router, it is (theoretically) possible you could simply set up a local DNS server to serve .home domains as well.
Essentially, you would need to:
Designate a PC to be your DNS server. It could be any PC on your network, but it would need to be consistently available (left on continuously) for DNS resolution.
Install DNS server software on that PC (e.g. BIND, Dnsmasq, etc.)
Configure the DNS server software to:
- Recognize ex.
pc1.homeandpc2.homevia e.g. individual zone files, with appropriate IP address mappings (likely the best option).
or
Resolve the entire
.homedomain and add ex.pc1.homeandpc2.hometo that zone file with appropriate IP address mappings (likely not the best option).Send all other requests upstream (e.g. to your ISP DNS servers).
- Recognize ex.
Point your router at your DNS server for DNS resolution (under the router's ex. Domain Name Server (DNS) Address settings). You would likely need to forward ports 53 and 953 to the DNS server as well.
.local domains
If you aren't tied to the .home domain, .local is typically used for mDNS (ZeroConf) DNS. Per the Wikipedia article on Multicast DNS (mDNS):
In computer networking, the multicast DNS (mDNS) protocol resolves hostnames to IP addresses within small networks that do not include a local name server. It is a zero-configuration service, using essentially the same programming interfaces, packet formats and operating semantics as the unicast Domain Name System (DNS).
mDNS is often available on various Linux distributions via avahi.