SSH and DHCP???

Ok, once again I have tried to search for an answer, and once again I have learned everything except how to fix the problem I have.

I am just trying to get SSH working between 2 local machines on OpensSuse 11.4 boxes. I have the SSHD daemon running, the firewall is configured to allow SSH to pass, and I am using SSH’s password authentication. However, my machines cannot see each other. Anytime I try to SSH, I get “Could not resolve hostname<hostname>: Name or service not known.”

Of course, that leads me to believe I need an entry in my /etc/hosts file. However, I use DHCP, and therefore have a dynamic IP address. Therefore, my hosts names will only be good until the next IP renewal. How in the world do I configure SSH with a DHCP assigned address?

Thanks in advance for any and all help!

There’s no easy answer to this.

Some routers will provide a simulated DNS service for this, if you are using the DNS service provided by DHCP (typically the router itself). My router allows me to assign preferred IP addresses, so I don’t have a problem. I just use “/etc/hosts”.

My previous router always gave the same IP, until I rebooted the router. What I did in that case, was assign a hostname in $HOME/.ssh/config. I used something like:

Host foobar

Then, whenever the router was rebooted, I would have to edit that file and change the IP. If I put all local host definitions in the one file, I can then use “scp” to copy the first one to the other machines and thus update those. I do use public key authentication so that I am not having to enter passwords for such copying.

Come to think of it, I also had to edit $HOME/.ssh/known_hosts, to avoid getting annoying error/warning messages. I also set

HashKnownHosts no

in /etc/ssh/ssh_config
so that the known_hosts lines are editable. I guess I could have done that in $HOME/.ssh/config instead.

I hope that gives you some useful ideas.

Some routers allow you to pin down the address handed out to a client with a given MAC address. You might look into that.

Hash: SHA1

The other obvious solution being… don’t SSH by DNS name (since you
don’t have DNS setup for it) or by hostname (since you don’t have your
hosts files hacked for it) but rather just SSH by IP address. The others’
responses about setting your IP “statically” via DHCP BootP-ish
configuration is the best way to go and every router I’ve seen in the last
several years supports this.

Good luck.

Want to yell at me in person?
Come to BrainShare 2011 in October:
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla -


Thank you all for your responses.

My router does support a local DNS, so assigning the names there appears to work. I’ll have to test it over power interruptions and the like, but that does seem to be the optimal solution.

Thanks again for the lessons :slight_smile: