Linux – How to assign names to devices on a LAN

linuxnetworking

I have a relatively small LAN containing a mixture of Mac, Windows and Linux devices. They currently all receive their IP address (fixed against MAC addresses) through DHCP and the DHCP server is also the router and default gateway. The subnet is 192.168.3.0 with a subnet mask of 255.255.255.0. For example:

  • default gateway: 192.168.3.254
  • Mac1: 192.168.3.1
  • Windows1: 192.168.3.2
  • Windows2: 192.168.3.3
  • Linux1: 192.168.3.4
  • Linux2: 192.168.3.5

I would like to be able to refer to different machines using a name rather than an IP address. For example, when ssh'ing from one Linux machine to another. If it's relevant, I don't have a company domain, etc.

What approaches can I take to achieve this?

Best Answer

For a network this small I'd just use

  • /etc/hosts (on Linux and OSX), or
  • c:\windows\system32\drivers\etc\hosts (on Windows).

If the network were to get much bigger I'd deploy dhcpd and named on one of the Linux boxes and stop using the router as the DHCP and DNS server.