** server can't find hostname.com nxdomain

PT_C picture PT_C · Jul 26, 2013 · Viewed 26k times · Source

I am trying to set up an apache web server on my vm and im running into some issues. When I do an 'nslookup' on the hostname of the machine this is what I get:

nslookup rhel64.xxxxx.xxxxx.com
Server:         xxx.xxx.32.1
Address:        xxx.xxx.32.1#53

** server can't find rhel64.xxxxx.xxxxx.com: NXDOMAIN

I'm sure this is a common problem but I'm not sure how to fix it. It seems that dnsmasq can't resolve the hostname. Adding the hostname to /etc/hosts doesn't fix it. Running on an RHEL6.4 machine. Thanks in advance.

Answer

Joni picture Joni · Jul 26, 2013

You should use a DNS server that is able to resolve the name; the one you are using now, at xxx.xxx.32.1, isn't.

Adding the hostname to /etc/hosts doesn't fix it.

This is because nslookup does a DNS lookup always, it does not read the hosts file. Try using getent instead, for example I get:

$ getent hosts rhel64.xxxxx.xxxxx.com
176.74.176.178  rhel64.xxxxx.xxxxx.com

(By the way, you should use example.com as an example almost always, so you don't inadvertently link to adult-only websites)