Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set up an Apache server on my RHEL6.4 vm and can't because dnsmasq can't recognize the hostname for some reason:


server can't find NXDOMAIN


xxx.x.x.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6


; generated by /sbin/dhclient-script
search novalocal

Please let me know if there is anything you need to see to solve my problem. I cannot use a different DNS server.

Looking for a way to make dnsmasq resolve the hostname without changing DNS servers.

share|improve this question
up vote 1 down vote accepted

I would expect IP address for your server to be fixed. Your /etc/hosts should contain  localhost localhost.localdomain localhost4 localhost4.localdomain4 
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
xxx.x.x.1 rhel64

localhost should never point to an address other than 127.0.01 or ::1. Add additional hosts with fixed addresses to /etc/hosts as required.

For dynamic addresses, make sure that you have set the correct domain in /etc/dnsmasq.conf, and ensure that the hostname is sent in the request. Check the dnsmasq.leases file which should be in the /var/lib directory try to verify. Domain should be specified like this.

Alternatively you can provide fixed addresses in the dnsmasq.conf file or /etc/ethers. A line like this will map mac address to DNS name would be specified in /etc/hosts as noted above.

EDIT: Diagnostics I would use include.

Running getent on the host with dnsmasq running.

 getent hosts rhel64

This should return the value you entered in the hosts file or returned by DNS. If that works try using the host command to lookup the address. Use nslookup if hosts is not available. Try these commands. (It appears your dnsmasq and apache servers are on the same host.

 hosts rhel64.
 hosts rhel64.  localhost
 hosts  localhost
 hosts rhel64.  rhel64. 
 hosts  rhel64.
 hosts rhel64.

Which command fails and how it fails should help you determine the problem. You may also want to ensure that dnsmasq is listening on all ip addresses.

When diagnosing the problem: Requests for rhel64. are for the host name unqualified with a domain, and requests for are for fully qualified name. The final dot on the names tells the resolver not to try domains from the search list. The second host name if specified overrides the name servers listed in /etc/resolv.conf. In this case, I have used the servers from /etc/resolv.conf, the local host address ( or ::1), the address of the hostname as looked up from DNS, and address of the fully qualified name as looked up from the name sever. The last two servers won't work if the initial look for the name failed.

 netstat -an | grep :53

EDIT: On re-reading your post, I notice you are getting your address from DHCP, the notes on setting a fixed IP address apply to Unix style DHCP servers. They should be applied to the dchp-server which is likely the router at xxx.x.x.1, which would not be your servers address. You should be able to get the curent IP address with either the command ifconfig or the newer command ip addr. This is the address which should be matched with your host name in the /etc/hosts file.

If you don't have access to the router, you can try to get DHCP to update the DNS service for you. Add the following entry to our DHCP configuration file: option fqdn.fqdn; or option fqdn.fqdn rhel64;

After adding the entry you will need to restart the dhclient process. Try the commands

sudo dhclient -r
sudo dhclient

Otherwise you will need to restart the interface or the entire networking setup.

share|improve this answer
I added the host and restarted the httpd and dnsmasq and I still get the error when I do an 'nslookup' on the hostname. – pt18cher Jul 30 '13 at 13:14
Server: Address: ** server can't find rhel64: SERVFAIL – pt18cher Jul 31 '13 at 12:24
Server: localhost Address: ::1#53 Name: rhel64 Address: 'host machine address' – pt18cher Jul 31 '13 at 12:24
Server: localhost Address: ::1#53 Name: Address: 'host machine name' – pt18cher Jul 31 '13 at 12:25
Server: Address: ** server can't find NXDOMAIN – pt18cher Jul 31 '13 at 12:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.