I have a fresh CentOS 7 install. During installation, I provided centa.home.local as hostname.

Now one of the software needs to see "host -v centa" output to locate the server IP address on server. Unfortunately it can't find the IP address.

[user1@centa ~]$ ifconfig | grep inet
        inet  netmask  broadcast
        inet6 fe80::20c:29ff:fe00:f049  prefixlen 64  scopeid 0x20<link>
        inet  netmask
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
[user1@centa ~]$ hostname
[user1@centa ~]$ hostname -d
[user1@centa ~]$ hostnamectl status
   Static hostname: centa.home.local
         Icon name: computer-vm
           Chassis: vm
        Machine ID: b2d53d8cc49e486f980d0f8461c415e2
           Boot ID: e2dbffd536434cc4ba530a17e8b186d6
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-514.el7.x86_64
      Architecture: x86-64
[user1@centa ~]$ cat /etc/hosts   localhost localhost.localdomain
::1         localhost localhost.localdomain centa.home.local centa
[user1@centa ~]$ cat /etc/resolv.conf 
# Generated by NetworkManager
search localdomain home.local
[user1@centa ~]$ host -v centa
Trying "centa.localdomain"
Trying "centa.home.local"
Trying "centa"
Host centa not found: 3(NXDOMAIN)
Received 98 bytes from in 136 ms
[user1@centa ~]$ 

1 Answer 1


Since the host utility is performing DNS lookups, it's not using /etc/hosts. Meaning for it to succeed, the host has to be in a DNS server somewhere.
Since the question is here, I'm assuming adding this DNS record to your DNS server (the one at is not an option. Fortunately you can actually solve this rather easy since you're using NetworkManager (as indicated by the comment line in your /etc/resolv.conf).

The solution is to enable & configure dnsmasq. dnsmasq is a DNS forwarder that runs on the local host. It can perform simple tasks such as recursive lookups, and caching the results. It can also do things like serving records from /etc/hosts. NetworkManager has built-in functionality for managing dnsmasq. So using it is very simple.


The configuration part is to tell dnsmasq to serve records from /etc/hosts, as the default configuration NetworkManager uses for dnsmasq does not enable this functionality.

Create the file /etc/NetworkManager/dnsmasq.d/hosts.conf with the following content:



Enabling is done by adding the dns = dnsmasq parameter to the [main] section of /etc/NetworkManager/NetworkManager.conf. For example:

dns = dnsmasq

After doing so, restart NetworkManager (via systemctl restart NetworkManager.service).


You should now notice that /etc/resolv.conf only has a single nameserver entry pointing to Any tools which consult /etc/resolv.conf to find the name servers should now end up hitting dnsmasq, and receive records found in /etc/hosts. If the record doesn't exist in /etc/hosts, the lookup will be forwarded to your upstream DNS server (

  • Trying your solution now... Jul 1, 2017 at 20:57
  • you saved me to run a separate DNS server. Thank you. Jul 1, 2017 at 21:28

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.