How do I use PuTTY to connect to a local server in a DHCP network without specifying the IP?

9,508

Solution 1

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.

Solution 2

You can configure dhcp to send a hostname with the dhcp request. Obviously you would need your dhcpd and nameserver to support this, but lots of routers support this feature so its worth checking if yours does.

Solution 3

Unfortunately, you're rather out of luck. In order to do this you need to use something like mDNS. It is implemented out of the box in OSX, called Bonjour, but hasn't reached critical mass outside of Apple yet. If you control the DHCP server you could set up DHCP Reservations for specific systems. In this scenario a nic with a specific MAC address will always get the same, statically defined, address from the DHCP server.

Solution 4

You won't be albo to resolve the address unless it's in some DNS server. You need to know the IP address or you can use some services like No-IP to update a FQDN to the servers current IP address. Of course this will only work for a server that has a public IP address.

For internal addresses you might want to write a script on the server that will send you the IP that is has at some point in time.

Solution 5

Some things in your question are still unclear, but i'll try to give a broad answer.

In order to connect to the machine via it's hostname, you need a name-resolution service active on the network - that is, a DNS or WINS server. Seeing that you say your machines cannot ping each other by name, it appears that you have no DNS server in the network (or that neither machine is set up with a primary DNS server). Which begs the question - what network enviroment would have DHCP but no DNS?

If there IS a DNS server on the network, then you just have to set both machines up to contact it (network connection properties in windows, god-knows-where.conf in linux) and you're all done.

Let's assume no DNS server then.

Assuming you have control over the DHCP server in your network, the easiest solution would be to set up a static ip mapping in the DHCP server. Make it give the linux server the same ip each time (bind a specific ip to the server's nic's MAC address). Then you can edit the hosts file on the windows workstation (found in %systemroot%\system32\drivers\etc) and map a specific name to the address, and enjoy yourself.

If you don't have control over the DHCP... Well, personally, i would just go bug the people who do (and tell them to get a DNS server in there for god sakes!)

I can think of other wild stuff that could circumvent all around this issue (write a script that pings the whole subnet, runs arp -a into a file, and then scans it to find the MAC address of the server, thereby resolving it's IP.. sheesh, this is sick). Seriously though, I would try to get a decent name resolution service up and running.

Share:
9,508

Related videos on Youtube

Jader Dias
Author by

Jader Dias

Updated on September 17, 2022

Comments

  • Jader Dias
    Jader Dias over 1 year

    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.

    • V. Romanov
      V. Romanov almost 15 years
      If ping couldn't resolve it, then it's a naming resolution service problem, not a putty problem. Can you ping other machines in the network by name? Give us more details please.
    • Jader Dias
      Jader Dias almost 15 years
      @Romanov My Windows desktop and my Linux server can ping themselves by the name. But they cannot ping each other by the name.
  • Matt Simmons
    Matt Simmons almost 15 years
    I agree. DNS is the solution
  • Jader Dias
    Jader Dias almost 15 years
    can I ping/connect to a MAC address, instead to an IP address?
  • Scott Pack
    Scott Pack almost 15 years
    Highly unlikely. There is a standard for inverse ARP (inARP), where you broadcast a MAC address and ask for the IP address. However, I have never actually used it, I only know that it was drafted as an RFC.
  • Fernando
    Fernando almost 15 years
    I have seen a Dynamic DNS server configured in a lab environment. Related idea but different implementation.