Cannot resolve localhost
matthew at FreeBSD.org
Thu Feb 14 23:02:54 UTC 2013
On 14/02/2013 22:35, Martin Pola wrote:
> I'm trying to get my FreeBSD system to resolve localhost into
> 127.0.0.1, but unfortunately it doesn't work. It appears the resolver is
> never reading from /etc/hosts, where I have this line:
> 127.0.0.1 localhost
> Here's a sample output of what I get when I try to resolve the name:
> $ nslookup localhost
> ;; Got recursion not available from 220.127.116.11, trying next server
> Server: 18.104.22.168
> Address: 22.214.171.124#53
> ** server can't find localhost: NXDOMAIN
> What am I missing?
The understanding that looking stuff up in the DNS[*] is never going to
return anything from the contents of your /etc/hosts file?
You can do a more generic lookup using whatever means are configured in
your /etc/nsswitch.conf by:
% getent hosts localhost
although with localhost, that really should also be available in the
DNS, both forwards and reverse:
% dig +short IN A localhost
% dig +short IN AAAA localhost
% dig +short -x 127.0.0.1
% dig +short -x ::1
Although I note that Google's DNS resolver specifically *doesn't* have it...
% dig +short @126.96.36.199 -x ::1
% dig +short @188.8.131.52 -x 127.0.0.1
% dig +short @184.108.40.206 localhost
% dig +short @220.127.116.11 IN AAAA localhost
Just a peculiarity of the Google DNS service.
[*] BTW. nslookup is *so* 20th Century. All the cool kids are using
dig(1) or drill(1) nowadays.
Dr Matthew J Seaman MA, D.Phil.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 268 bytes
Desc: OpenPGP digital signature
More information about the freebsd-questions