Unable to resolve hostname for Redhat Linux server
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.
Related videos on Youtube
Comments
-
L P over 1 year
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 [email protected]
, instead ofssh [email protected]
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 bydhclient 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
-
Matej Vrzala M4 over 8 yearsDid you add the hostname to your /etc/hosts file?
-
L P over 8 yearsYes, I had:
127.0.0.1 localhost localhost.localdomain xx.xxx.xx.xxx myhostname.blah.di.blah
.. updated description to include this. -
Matej Vrzala M4 over 8 yearsOk.. what happens when you ping the domain?
-
L P over 8 yearsWhen I ping IP - I get the correct response, pinging domain returns
ping: unknown host myhostname.blah.di.blah
-
Matej Vrzala M4 over 8 yearsOk 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...
-
L P over 8 yearsIt doesn't work either. I'm not sure where is the "dhcp-xx-xxx-xx-xxx" bit coming from, it just needs to be populated with 'myhostname'. Don't know which config. needs to be updated to achieve this.
-