How to set up local domain name (.home)?
Solution 1
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.
Solution 2
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: https://www.makeuseof.com/tag/modify-manage-hosts-file-linux/
Solution 3
What exactly is the
.home
domain? 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.home
ex. hosts
(PC 2 → 10.0.0.20
)
10.0.0.10 pc1.home
The 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.home
andpc2.home
via e.g. individual zone files, with appropriate IP address mappings (likely the best option).
or
-
Resolve the entire
.home
domain and add ex.pc1.home
andpc2.home
to 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.
Related videos on Youtube
hm1912
Updated on September 18, 2022Comments
-
hm1912 over 1 year
Assume I have two computers with hostnames
pc1
andpc2
in my local network10.0.0.0/24
. My router has the ip address10.0.0.138
and its instructions say that it is also reachable atmodem.home
, which I tried and is true.I want to connect from
pc1
topc2
via ssh and use its hostname, not its ip for that. However, thehost
commando under linux gives me this result when using the ip address ofpc2
: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
.home
domain? 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)?
-
xenoid about 4 years
.home
is likely set by your router.
- What exactly is the
-
hm1912 about 4 yearsI would need to set static ip addresses for them though, wouldn't I? Otherwise they could get another ip the next day and then the host entries wouldn't work any longer
-
John about 4 yearsYou can set up static IP addresses if you wish. I set an association in my router relating IP address to MAC address so that my main computer always get the same IP address. I need this for my own HOSTS file so that my Sync Application can always find the machine. The process is similar to IP Reservation on a Server.