7

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.

PT_C
  • 1,178
  • 5
  • 24
  • 57

1 Answers1

6

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)

Joni
  • 108,737
  • 14
  • 143
  • 193
  • Are you the sysadmin for the DNS server? `getent hosts` looks up names from the different services available to the system in the order specified in `/etc/nsswitch.conf`, make sure the line for "hosts" says "files" before "dns" – Joni Jul 26 '13 at 13:27
  • Is there a way to add the name to a dns conf file so where it CAN resolve it? If not what would be an alternate DNS server? – PT_C Jul 26 '13 at 13:30
  • I am the sysadmin yes – PT_C Jul 26 '13 at 13:31
  • getent now returns the host name of the vm. Still not able to test an html file from the browser – PT_C Jul 26 '13 at 14:09
  • If `getent` is able to resolve the name so is Firefox. It's possible that Apache is not well configured. What error do you get? `dnsmasq` reads the ip-to-host assignments from /etc/hosts and from other files you specify, depending on settings in the config file or on the command line. – Joni Jul 26 '13 at 14:22
  • I created a simple html file that I use for reference. When I type in http://hostname/index.html I get a time out error in the browser as well as the error listed in the initial question – PT_C Jul 26 '13 at 14:24
  • Since I am only testing, dnsmasq is what were staying with. Any idea on how to fix it without changing the DNS server? – PT_C Jul 29 '13 at 19:18