AnyEvent resolves hostnames always via DNS
Dirk Koopman
djk at tobit.co.uk
Wed Mar 7 23:51:53 CET 2012
On 07/03/12 19:45, Marc Lehmann wrote:
> 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.
>
Actually, this is rather misleading as in so many subtle ways a lack of
an /etc/hosts file (or misconfiguration thereof) will prevent an X
system (for instance) from working correctly - annoyingly - usually in a
very inconsistent fashion.
>
> 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.
>
The default order has traditionally been hosts,bind (as can be seen in
linux /etc/hosts.conf). I know people that rely on this order to allow
them to *override* DNS lookups.
Dirk
More information about the anyevent
mailing list