Linux – How to use PuTTY to connect to a local server in a DHCP network without specifying the IP

linuxnetworkingputtysshwindows

I don't want to specify an IP address, since it can change in a DHCP LAN. I tried to connect to the linux server's name, but neither Putty nor Windows' ping.exe could resolve it.

Best Answer

I can see solutions in a couple of categories:

  1. Static IP:
    1. Fix the IP on the Linux machine and exclude that IP from the DHCP server.
    2. Get the DHCP server (your router?) to give the Linux server's MAC address a fixed address.
    3. For either of these, put the static IP address in your client's hosts file.
  2. Dynamic IP with DNS.
    1. Find some way of having the Linux machine send a hostname with it's DHCP request, and having the DHCP server/DNS server expose this name so DNS resolution will work. Depends on DHCP and DNS servers.
    2. Put the Linux server's current IP on some fixed shared resource (e.g. external web-page). And script something hacky on the client to get that and use it as the server IP address.