Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

nslookup rhel64.example.com
Server:         xxx.xxx.xx.1
Address:        xxx.xxx.xx.1#53

server can't find rhel64.exmple.com: NXDOMAIN

/etc/hosts:

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

/etc/resolv.conf:

; generated by /sbin/dhclient-script
search novalocal example.com
nameserver xxx.xxx.xx.1

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

1 Answer 1

up vote 0 down vote accepted

I would expect IP address for your server to be fixed. Your /etc/hosts should contain

127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4 
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
xxx.x.x.1  rhel64.example.com 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.

domain=example.com

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

 aa.bb.cc.dd.ee.ff     192.0.2.1

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.example.com.
 hosts rhel64.  localhost
 hosts rhel64.example.com.  localhost
 hosts rhel64.  rhel64. 
 hosts rhel64.example.com.  rhel64.
 hosts rhel64.  rhel64.example.com.
 hosts rhel64.example.com.  rhel64.example.com.

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 rhel64.example.com. 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 (127.0.0.1 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 rhel64.example.com; 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: xxx.xxx.xx.1 Address: xxx.xxx.xx.1#53 ** 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: rhel64.example.com Address: 'host machine name' –  pt18cher Jul 31 '13 at 12:25
    
Server: xxx.xxx.xx.1 Address: xxx.xxx.xx.1#53 ** server can't find rhel64.example.com: NXDOMAIN –  pt18cher Jul 31 '13 at 12:25

Your Answer

 
discard

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.