Linux – added entry to hosts file (ubuntu); can ping ok; cannot nslookup

apache-http-serverdnslinuxUbuntu

added entry to /etc/hosts

 127.0.0.1    testjd.com

can ping ok

ping testjd.com

PING test.com (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.100 ms

but nslookup (and apache2 config) can't resolve the new name…

nslookup testjd.com
;; connection timed out; no servers could be reached

sudo /etc/init.d/apache2 reload
[error] (EAI 2)Name or service not known: Could not resolve host name > -- ignoring!

note: cat /etc/host.conf

order hosts,bind
multi on

what i ultimately want to achieve is for my apache2 config to be able to resolve the new local name (note: i configured a virtualhost for testjd.com, but i can't get past the "resolve host name" problem shown above)

thanks.

Best Answer

This is because the nslookup command works with a DNS, and your DNS can't find testjd.com. You can use the host command instead, which will interact with your hosts file.

john@awesome:~$ host localhost
localhost has address 127.0.0.1
localhost has IPv6 address ::1
Related Question