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 foobar.domain.name
        HostName 192.168.1.15

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.

-----BEGIN PGP SIGNED MESSAGE-----
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: http://tinyurl.com/brainshare2011
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOP1VTAAoJEF+XTK08PnB5AZkQAJdpM7/X29qRFG9xClQxcZ1N
FY4E20UnBp/DtGMLz5r0wSa+dIOmhxagHMup4R0LDoAeTyJNMCW6KSZc9kwUbGp/
RGiio+sMyyTe+YheEpLwgQIEJcvZQe+5duEl+D4BQukTWawzzVdQSNuAYxqU1gLR
quSuW3bygUPGxAltHBRwmh3s1+P7+SYYxCYFlxC6FduaL9RBFw7M65Z6VQye8u5x
hfu3SVPoz0/OFnKecSUa7MAEDhppT+PMd3XJ3bP8DqSa5TLkWATTYU0unCnZn8IV
OAzNwUFfXMUjdkwHdVcQMFgITcABeHQnZdmC6r9xMfnK7Ikg2Ibwzg3GjOmRjtyJ
UQ7cTt+++ZNnDOQaSWl1nztyGjK6SEX4hJflNO+zQnRTpOGMuukpgRfNNOvCPDfA
0W0E8VpPwVM4vnIrjEypd3lKlVyEXnhge/AlkJPsnywwRp9CpaZEOEsth6u7BsWR
CApKsgXq5a+y7pujBFT0DYL7AFR3PTn1Wl5VsUzeTxRp7T7l9/0+/ZAVWMsoQ2wg
mhjFohLiQQJ4O5Xmc25C1NdzhcbmrhkHFm94E2L9/IKS2h6bRdiUS2S0TJH1nB1l
Cnanm4JY+244ni1OzvzvHR4xnvun8DXMisE2kRVTqk1O2g9Zea+bbmRywwpfv7t3
OTfASKwyy2nCJXc1LgqL
=dtoV
-----END PGP SIGNATURE-----

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: