I have CentOS 6.7 x64 (Final) Desktop standard installation, on a dedicated pc (not on a VM), Linux version 2.6.32-573.el6.x86_64 (gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) ).

I've configured my /etc/sysconfig/network-scripts/ifcfg-eth0 file as follow:

DNS2= ,


chkconfig network on
service network start

After, I've modified my /etc/hosts and /etc/sysconfig/network as: localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6 srvr1.cloud.priv ,


service network restart .

As result, I've got that I can go on the web (I'm on with this configuration by now), but when I run:

hostname --fqdn ,

it returns:

hostname: No address associated with name

instead of a correct FQDN response.

I would need to know how to solve this situation and get the right output.

PS: I don't know if it has something to do with this problem, but my modem-router has the DHCP activated and the provider does not allow to disable it (or better, it can not be disabled by the user with official versions of the firmware).


You can set the hostname using hostname command hostname man page

From the man page, "Hostname is the program that is used to either set or display the current host, domain or node name of the system. These names are used by many of the networking programs to identify the machine. The domain name is also used by NIS/YP.

You can't change the FQDN (as returned by hostname --fqdn) or the DNS domain name (as returned by dnsdomainname) with this command. The FQDN of the system is the name that the resolver(3) returns for the host name. Technically: The FQDN is the name gethostbyname(2) returns for the host name returned by gethostname(2). The DNS domain name is the part after the first dot.

Therefore it depends on the configuration (usually in /etc/host.conf) how you can change it. Usually (if the hosts file is parsed before DNS or NIS) you can change it in /etc/hosts.

If a machine has multiple network interfaces/addresses or is used in a mobile environment, then it may either have multiple FQDNs/domain names or none at all. Therefore avoid using hostname --fqdn, hostname --domain and dnsdomainname. hostname --ip-address is subject to the same limitations so it should be avoided as well."

Add to your /etc/hosts a reference to with the fqdn as first row, and it should work.

EDIT: I noticed you changed the with the IP of the machine. You always must have in your /etc/hosts, as this indicates the loopback interface which is used by different applications and services.

| improve this answer | |

Try setting your hostname:

# hostame srvr1.cloud.priv

Then edit your /etc/hostname file to have it stick on reboot.


| improve this answer | |
  • Hello and thank you. When I run "hostame srvr1.cloud.priv" , it returns "hostname: No address associated with name". I don't know how to fix it, please help. – joe Jan 28 '16 at 20:51
  • Apologies for not responding until now. According to this, you may need to edit /etc/hostname first, then use the hostname command. Try switching the order around. – Ben Feb 5 '16 at 16:56

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.