How to use host names rather than ip addresses on home network?

I've a small home network up and running and managed to set up ssh. Can anyone tell me what I need to do to refer to one computer on the network from another by host name rather than IP address (which is what I'm doing now)?


You can refer to machines by by tacking a .local to the hostname, like so:

ssh machinename.local

References:

  • What does ".local" do?

There are more elaborate ways, but my method is to use static IP addressed, which I can assign from my router, and enter the addresses into my hosts file.

Once you get a static address assigned, either from the router or from the Network Connections dialog (in the IPv4 tab under the Wired or Wireless tab), you edit /etc/hosts, using sudo or gksu with your preferred text editor, such as gedit or vim, and add a line for each host like so:

192.168.1.100    ComputerName1
192.168.1.101    ComputerName2

The numbers I use are common ones, but your LAN could be different. The names are whatever you want to call the remote computer, and can be anything (though probably best to match the real name). You can also create local websites by name here, if you have a local web server.