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.

  • 1
    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. – V. Romanov May 30 '09 at 19:51
  • @Romanov My Windows desktop and my Linux server can ping themselves by the name. But they cannot ping each other by the name. – Jader Dias May 30 '09 at 19:54

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.

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.

  • I agree. DNS is the solution – Matt Simmons May 30 '09 at 19:52
  • I have seen a Dynamic DNS server configured in a lab environment. Related idea but different implementation. – pcapademic May 31 '09 at 9:17

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.

  • can I ping/connect to a MAC address, instead to an IP address? – Jader Dias May 30 '09 at 19:58
  • 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. – Scott Pack May 30 '09 at 20:06

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.


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.


I also have Linux server on a DHCP network. The easiest way I've found to use DHCP and still be able to easily connect to the server is to give it a static ip. You can still use DHCP for other clients, but have a static ip for your server.

You don't say what Linux distro you use, but here's the relevant part of my rc.conf from Arch Linux.

eth0="eth0 netmask broadcast"
INTERFACES=(lo eth0)

gateway="default gw"

As others have pointed out, the problem is with name resolution, not SSH.

But the best solution is to configure the DNS, DHCP Server and DHCP Client so that a DNS entry is created automtaically for all the DHCP clients. This is easily done with Microsoft's DHCP server (I should be able to provide instructions if that's helpful) but should also be possible with other servers.

Basically you need:

  1. A DNS server that accepts dynamic updates (you may want to secure this).
  2. A DHCP server that sends a dynamic update for all clients (MS DHCP server will do this, but doesn't by default).
  3. A DHCP client that tells the DHCP server its name (most do this automatically, but it may be an option that needs turning on).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.