AnyEvent resolves hostnames always via DNS
Marc Lehmann
schmorp at schmorp.de
Wed Mar 7 20:45:08 CET 2012
Hi, thanks for your interest!
On Tue, Mar 06, 2012 at 08:04:03PM +0100, Piotr Roszatycki <piotr.roszatycki at gmail.com> wrote:
> Yesterday I noticed, that AnyEvent::Socket::resolve_sockaddr works
> different than on every Linux box
That's not a true statement (as you should be well aware of :).
> and it lookups DNS even if address is in /etc/hosts.
Yes, that's what it should do.
> The most default configuration of Name Service Switch:
AnyEvent doesn't implement nss indeed, AnyEvent implements DNS lookups.
> The order of resolving a socket address is important because
> /etc/hosts works even if i.e. nameserver is unavailable (problem with
That is what indeed should happen - does it not?
> possible local overring (spoofing) some addresses outside our network.
No, that's not the purpose of /etc/hosts - the purpose of /etc/hosts is to
bootstrap the box until DNS is available, then DNS takes over.
See hosts(5), which is liekly identical on your system:
In modern systems, even though the host table has been superseded
by DNS, it is still widely used for:
bootstrapping Most systems have a small host table containing the
name and address information for important hosts on the
local network. This is useful when DNS is not running, for
example during system bootup.
NIS Sites that use NIS use the host table as input to the NIS host
database. Even though NIS can be used with DNS, most NIS
sites still use the host table with an entry for all local
hosts as a backup.
isolated nodes Very small sites that are isolated from the network
use the host table instead of DNS. If the local information
rarely changes, and the network is not connected to the
Internet, DNS offers little advantage.
AnyEvent supports all of these. If it doesn't work, then there is a bug.
> AnyEvent works differently: it uses DNS even if address is already
> found in /etc/hosts.
AnyEvent looks up via DNS, then via /etc/hosts, as it should do,
because /etc/hosts doesn't have enough information (it's not a DNS
replacement). It is used as a fallback when DNS fails, or should be at
least.
> some $ENV{PERL_ANYEVENT_*} settings could disable mandatory DNS
> lookup.
DNS isn't mandatory, AnyEvent supports /etc/hosts, or at least, I have
no evidence that it doesn't do so. Maybe you used the wrong syntax for
/etc/hosts or AnyEvent couldn't parse your entry for other reasons? OR
maybe you had a matching entry in DNS?
> Is it possible to change the default AnyEvent's behavior and make some
> applications working without DNS?
Since AnyEvent already works that way, there doesn't seem to be a need
to change anything, but there is always the possibility that something
goes unexpectedly wrong - however, it seems to me that this is a case of
misunderstanding the purpose of /etc/hosts.
So, if /etc/hosts don't work as a fallback, then could you send me
your /etc/hosts and a small snippet that fails to resolve the hostname
properly?
Thanks a lot!
--
The choice of a Deliantra, the free code+content MORPG
-----==- _GNU_ http://www.deliantra.net
----==-- _ generation
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / schmorp at schmorp.de
-=====/_/_//_/\_,_/ /_/\_\
More information about the anyevent
mailing list