Hostname is not resolving on server

Latest response

It is not resolving its local hostname from server i.e (portalepd) , but other hostname and domain name is working fine. Because of that hostname -f is not working on server. Please require your advice ========================================================== [root@portalepd Packages]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.1.22.127 portalepd portalepd.cmpc.cl 10.1.24.160 cmpcibm105.cmpc.cl cmpcibm105
[root@portalepd Packages]# ping portalepd ping: unknown host portalepd [root@portalepd Packages]# hostname -f hostname: Temporary failure in name resolution
[root@portalepd Packages]# cat /etc/resolv.conf

Generated by NetworkManager

No nameservers found; try putting DNS servers into your

ifcfg files in /etc/sysconfig/network-scripts like so:

# DNS1=xxx.xxx.xxx.xxx

DNS2=xxx.xxx.xxx.xxx

DOMAIN=lab.foo.com bar.foo.com

search cmpc.cl
nameserver 10.1.24.174
nameserver 172.20.4.112

Responses

The hosts entry in /etc/nsswitch.conf specifies the order of resolving names. The following entry will first consult /etc/hosts and then DNS:

hosts: files dns

You may try this.. run "sysctl -n kernel.hostname", if this is not matching with /etc/hosts files then fix this by running "sysctl -w ". Also, correct your hostname entry in /etc/hosts file, it should be like this .. 172.18.1.100 testserver.example.com testserver

After you could run the command "hostname -fv" to check if it is resolving local name resolution.

Subhendu Patanga,

Some additional thoughts...

I see your /etc/hosts and /etc/resolv.conf files above. How do these files compare to a system that is functioning with hostname -f on your network? (especially /etc/resolv.conf)?

Is there any chance that NetworkManager clobbered your /etc/resolv.conf and your system can no longer see the nameservers (dns servers)? Just in case, check once again your /etc/resolv.conf as it is currently against another system that works properly. NetworkManager will clobber /etc/resolv.conf upon a network restart or system reboot unless you either tell it not to with a proper PEERDNS directive, or simply make the entries for DNS1 and DNS2 etc in your interface file.

Make a backup of your /etc/hostname file (this is overkill, but it's nice to know what it was prior)

cp /etc/hostname /etc/hostname.bak

If you do need to fix your hostname.... (rhel7) hostnamectl set-hostname correctnameofyourserver.cmpc.cl is a way to set your hostname with the FQDN, however MAKE SURE this is exactly what is proper (like in case you have a signed certificate that a database or something relies on and fails due to a mismatch of a certificate, this is rare, and I only know of one customer this applied to).

You could do what the output you pasted above and define entries for DNS1 and DNS2 in your /etc/sysconfig/network-scripts/ifcfg-CORRECT_INTERFACE_FILE (please make a backup in a different directory, not the same directory prior to doing this).

This Red Hat solution I post in this sentence is unlikely, but I offer it to you for reference https://access.redhat.com/solutions/2705561

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.