Solved How to Use /etc/hosts

This is a fresh install of FreeBSD 13.1. Local unbound is not enabled. The file /etc/resolv.conf is:

Code:
nameserver 192.0.2.1

I have also added a line to /etc/hosts

Code:
192.168.0.10        test.local test

When I use drill, the hostname in /etc/hosts is ignored.

What am I doing wrong?

I have substituted an RFC 5737 documentation IP address, 192.0.2.1, for the real DNS server in the example resolv.conf shown above. The real DNS server works just fine for all drill queries to the outside world. I just don't want to put the real IP address in this post.
 
That explains that. I was using drill because I noticed that nslookup and dig are not part of the base system (anymore? ever before?). I know that you're going to say that dig is like drill and also ignores DNS servers.

Is there a tool in the base system for testing DNS?
 
I noticed that nslookup and dig are not part of the base system (anymore? ever before?)
dig(1) and nslookup(1) are part of the BIND suite, BIND got removed from the base with 9.0 (If I remember correctly). drill(1) was added to the base as a replacement for dig(1). If you want those tools install dns/bind-tools.

Is there a tool in the base system for testing DNS?
hosts(5) is not DNS. You're not looking to test DNS, you're looking to test name resolving. There is a difference.
 
host(1) is for DNS queries as well. Indeed, ping(8) is a quick and easy way to test name resolution as a side effect.

If you want to test it directly, use getent(1), e.g. like this:
Code:
# getent hosts localhost
::1               localhost  localhost.my.domain
127.0.0.1         localhost  localhost.my.domain
# getent hosts google.com
2a00:1450:4001:80b::200e  google.com
172.217.18.14     google.com
 
SirDice Yes, I did keep saying test "DNS" when I meant test local C resolver.

zirias@ covacat Thanks! That's exactly what I'm looking for: getent and ping do exactly what I need for testing local C resolver.
 
Back
Top