0

I've setup a Linux Red Hat server and would like to use it by referring to its hostname instead of the static IP.

eg. ssh admin@myhostname.blah.di.blah, instead of ssh admin@XX.XXX.XX.XXX

but I get a message:

ssh: Could not resolve hostname myhostname Name or service not known.

OR

If I do a nslookup from a windows client I get this such that it can detect the IP but I see dhcp-IP instead of my set hostname:

Server:  UnKnown
Address:  1903:ad:8s10::fd
Name:    dhcp-xx-xxx-xx-xxx.blah.di.blah
Address:  xx.xxx.xx.xxx

As per several other stackoverflow posts, I set the hostname in:

/etc/sysconfig/network-scripts/ifcfg-eth0

as

DHCP_HOSTNAME=myhostname.blah.di.blah

I made the changes and did a dhclient -r followed by dhclient eth0 but no luck.

Also, my /etc/hosts file looks like this:

127.0.0.1  localhost localhost.localdomain
xx.xxx.xx.xxx myhostname.blah.di.blah
  • Did you add the hostname to your /etc/hosts file? – ryekayo Dec 11 '15 at 15:30
  • Yes, I had: 127.0.0.1 localhost localhost.localdomain xx.xxx.xx.xxx myhostname.blah.di.blah.. updated description to include this. – L P Dec 11 '15 at 15:44
  • Ok.. what happens when you ping the domain? – ryekayo Dec 11 '15 at 15:45
  • When I ping IP - I get the correct response, pinging domain returns ping: unknown host myhostname.blah.di.blah – L P Dec 11 '15 at 15:46
  • Ok one last thing you can try is changing your ~/.ssh/config file to associate the IP address with the host.. This is definitely a DNS problem... – ryekayo Dec 11 '15 at 15:47
1

If you are trying to reach the system by hostname from another system, it will not work. You will need to either set up a DNS server on your network and add these entries, or manually add the hostname to the hosts file of the remote system you are using.

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.