Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Does bind read /etc/hosts?

2,989 views
Skip to first unread message

houguanghua

unread,
Jul 15, 2014, 6:28:30 AM7/15/14
to bind-...@lists.isc.org
Dear sir/madam,
 
Before Bind consults authority NS, does it access /etc/hosts?  In my testing,  it does not even seem to access /etc/hosts. But someone tells me Bind can access /etc/hosts first. Can you pls tell me how to config Bind to access /etc/hosts fist?
 
Thanks,
Guanghua

Mark Andrews

unread,
Jul 15, 2014, 6:38:12 AM7/15/14
to houguanghua, bind-...@isc.org
No.

getaddrinfo, gethostbyname etc. however may access /etc/hosts, NIS,
mDNS, DNS and other databases. You need to read the documentation
that comes with your system for how to control these.

Mark
--
Mark Andrews, ISC
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742 INTERNET: ma...@isc.org

Niall O'Reilly

unread,
Jul 15, 2014, 6:56:47 AM7/15/14
to houguanghua, bind-...@lists.isc.org
At Tue, 15 Jul 2014 10:28:30 +0000,
houguanghua wrote:
>
> Before Bind consults authority NS, does it access /etc/hosts? In my
> testing, it does not even seem to access /etc/hosts.

That's right. BIND tools (dig, ...) are DNS tools.
Local files aren't part of the DNS.

For more information, please see
http://serverfault.com/questions/498500/why-does-the-host-command-not-resolve-entries-in-etc-hosts

Best regards,
Niall O'Reilly

Lightner, Jeff

unread,
Jul 15, 2014, 1:15:03 PM7/15/14
to bind-...@lists.isc.org

The confusion can come in because some UNIX variants (notably HP-UX) nslookup was modified to honor /etc/nsswitch.conf so it DOES check /etc/hosts if "files" precedes "dns".

However, in most things (e.g. Linux, Solaris) nslookup (and the newer host command) do not look at /etc/hosts regardless of nsswitch.conf setting.
_______________________________________________
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe from this list

bind-users mailing list
bind-...@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users

Athena(r), Created for the Cause(tm)
Making a Difference in the Fight Against Breast Cancer

__________________________________________________________
CONFIDENTIALITY NOTICE: This e-mail may contain privileged

or confidential information and is for the sole use of the intended

recipient(s). If you are not the intended recipient, any disclosure,

copying, distribution, or use of the contents of this information

is prohibited and may be unlawful. If you have received this electronic

transmission in error, please reply immediately to the sender that

you have received the message in error, and delete it. Thank you

houguanghua

unread,
Jul 15, 2014, 9:27:17 PM7/15/14
to Mark Andrews, bind-...@isc.org
Sorry for what I said isn't very clear. I did know when the /etc/hosts is accessed in the OS.
What I want to know is whether the named access the hosts file. The /etc/hosts file isn't in the client's system, but in the system of Local DNS server where the 'named' task runs. For example:
      In the /etc/hosts file of Local DNS server(LDNS), one line exists as follows:
          10.10.10.1     www.google.com  
     A client querys this LDNS to get the IP of 'www.google.com' (the client may use dig,nslookup command. No host line is configured in /etc/hosts of this client ), what IP will be returned to the client?  Can the LDNS  return 10.10.10.1 defined in the /etc/hosts to the client?  maybe some special configuration in named can support this feature.
 
Thanks,
Guanghua
 

> Subject: Re: Does bind read /etc/hosts?
> Date: Tue, 15 Jul 2014 20:38:12 +1000

>
>
> In message <BAY173-W11D824E32...@phx.gbl>, houguanghua writes:
> > Dear sir/madam,
> >
> > Before Bind consults authority NS, does it access /etc/hosts? In my

Mark Andrews

unread,
Jul 15, 2014, 9:33:00 PM7/15/14
to houguanghua, bind-...@isc.org

In message <BAY173-W26F0D751D...@phx.gbl>, houguanghua writes:
> Sorry for what I said isn't very clear. I did know when the /etc/hosts is
> accessed in the OS.
> What I want to know is whether the named access the hosts file.

And I gave you a clear, unequivicable "No". Named does not
read /etc/hosts.

Mark

houguanghua

unread,
Jul 15, 2014, 9:43:42 PM7/15/14
to Mark Andrews, bind-...@isc.org
 Thanks a lot.
 
> To: hougu...@hotmail.com
> CC: bind-...@isc.org
> From: ma...@isc.org
> Subject: Re: Does bind read /etc/hosts?
> Date: Wed, 16 Jul 2014 11:33:00 +1000

Karl Auer

unread,
Jul 15, 2014, 9:56:14 PM7/15/14
to bind-...@lists.isc.org
> > > What I want to know is whether the named access the hosts file.

I wonder if the OP is actually asking for a way to have BIND return
specific values for specific host names, without having them looked up
in the real DNS.

Guanghua, can you tell us the result you wish to achieve? From your
example, it looks as if you are trying to get BIND to return a value of
your choice, rather than the value that would normally be returned by a
DNS lookup.

Regards, K.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (ka...@biplane.com.au)
http://www.biplane.com.au/kauer
http://twitter.com/kauer389

GPG fingerprint: EC67 61E2 C2F6 EB55 884B E129 072B 0AF0 72AA 9882
Old fingerprint: B862 FB15 FE96 4961 BC62 1A40 6239 1208 9865 5F9A


Reindl Harald

unread,
Jul 15, 2014, 10:44:36 PM7/15/14
to bind-...@lists.isc.org

Am 16.07.2014 03:27, schrieb houguanghua:
> Sorry for what I said isn't very clear

you wheer clear

> I did know when the /etc/hosts is accessed in the OS

agreed

> What I want to know is whether the named access the hosts file
> The /etc/hosts file isn't in the client's system,

for bind applies the same as for bind-utils (dig, nslookup...)
anything else would be strange and unpredictable behavior

> but in the system of Local DNS server where the 'named' task runs. For example:
> In the /etc/hosts file of Local DNS server(LDNS), one line exists as follows:
> 10.10.10.1 www.google.com

bind don't care about that

> A client querys this LDNS to get the IP of 'www.google.com' (the client
> may use dig,nslookup command. No host line is configured in /etc/hosts
> of this client ), what IP will be returned to the client?

the one of the DNS system

> Can the LDNS return 10.10.10.1 defined in the /etc/hosts to the client?
> maybe some special configuration in named can support this feature

wrong tool - > dnsmasq can but on the other hand has no bind-like zonefiles

signature.asc

Mark Andrews

unread,
Jul 15, 2014, 10:55:48 PM7/15/14
to Reindl Harald, bind-...@isc.org

In message <53C5E714...@thelounge.net>, Reindl Harald writes:
> > Can the LDNS return 10.10.10.1 defined in the /etc/hosts to the
> > client?
> > maybe some special configuration in named can support this feature
>
> wrong tool - > dnsmasq can but on the other hand has no bind-like
> zonefiles

Neither dnsmasq nor named read /etc/hosts. Both can be used to
override data from outside. They just have different configuration
methods.

Fajar A. Nugraha

unread,
Jul 15, 2014, 11:03:09 PM7/15/14
to bind-...@isc.org
On Wed, Jul 16, 2014 at 9:55 AM, Mark Andrews <ma...@isc.org> wrote:
>
> In message <53C5E714...@thelounge.net>, Reindl Harald writes:
>> > Can the LDNS return 10.10.10.1 defined in the /etc/hosts to the
>> > client?
>> > maybe some special configuration in named can support this feature
>>
>> wrong tool - > dnsmasq can but on the other hand has no bind-like
>> zonefiles
>
> Neither dnsmasq nor named read /etc/hosts.

>From dnsmasq man page:
"
... It loads the contents of /etc/hosts so that local hostnames which
do not appear in the global DNS can be resolved and also answers DNS
queries for DHCP configured hosts"

So dnsmasq does read /etc/hosts. Or did you mean something else?

--
Fajar

Reindl Harald

unread,
Jul 15, 2014, 11:05:10 PM7/15/14
to bind-...@isc.org

Am 16.07.2014 04:55, schrieb Mark Andrews:
> In message <53C5E714...@thelounge.net>, Reindl Harald writes:
>>> Can the LDNS return 10.10.10.1 defined in the /etc/hosts to the
>>> client?
>>> maybe some special configuration in named can support this feature
>>
>> wrong tool - > dnsmasq can but on the other hand has no bind-like
>> zonefiles
>
> Neither dnsmasq nor named read /etc/hosts. Both can be used to
> override data from outside. They just have different configuration
> methods

surely, otherwise "--no-hosts" or the config param to disable
that would not make sense, using it with ATS in production

[root@localhost:~]$ dnsmasq --help | grep no-hosts
-h, --no-hosts Do NOT load /etc/hosts file.

-H, --addn-hosts=<file>
Additional hosts file. Read the specified file as well as /etc/hosts.
If -h is given, read only the specified file. This option may be
repeated for more than one additional hosts file. If a directory
is given, then read all the files contained in that directory.

[root@localhost:~]$ cat /etc/dnsmasq.conf
resolv-file=/etc/resolv.conf.dnsmasq
strict-order
user=nobody
group=nobody
interface=lo
no-dhcp-interface=lo
bind-interfaces
no-hosts
addn-hosts=/etc/hosts.dnsmasq
local-ttl=3600

signature.asc

Mark Andrews

unread,
Jul 15, 2014, 11:22:30 PM7/15/14
to Reindl Harald, bind-...@isc.org

Ok, I stand corrected. That said both named and dnsmasq as well
as other products can override data from outside.
0 new messages