Re: Any way to bypass nameserver call in IPV6 ???

From: Dale Talcott (aeh_at_quest.cc.purdue.edu)
Date: 08/27/04


Date: 27 Aug 04 08:49:15 EST

bennett.tony@cnf.com (T.R.Bennett) writes:

>Apache and several other open source projects have converted
>their code from using gethostbyname() to using getaddrinfo().

>They call getaddrinfo with a hints.ai_family = AF_UNSPEC,
>which means "get me both IPV4 as well as IPV6" addresses.

>If I were using gethostbyname(), then I could prevent going
>to the nameserver if I have the host in the /etc/hosts file
>and had /etc/netsvc.conf contain "hosts= local,bind".

>How do I create the same behaviour for IPV6 addresses ?

I cannot answer this part. My guess is that you would need to put IPv6
addresses in /etc/hosts. The docs suggest that is supported, but I
could not find an example.

Now, if you want to get rid of IPv6 queries entirely, use
"hosts=local4,bind4".

>Additionally, I noted that even though I specify a FQDN in
>the getaddrinfo() call, it tries both that name as well as
>a name created by appending my domain name. For example:
> - I specify XXX.YYY.COM
> - getaddrinfo does IPV6 queries for:
> XXX.YYY.COM
> XXX.YYY.COM.YYY.COM
>Is this correct behaviour???

Assuming there is no IPv6 info for XXX.YYY.COM, then it is correct.

I believe you can get rid of the second query by using a resolv.conf
patterned after ours:

        search cc.purdue.edu rcs.purdue.edu purdue.edu
        options ndots:2
        nameserver 127.0.0.1
        nameserver 128.210.11.57

That is, replace the domain line with a search line, listing the
various (sub)domains you would like searched for short names (see
next for definition of "short"). In our example, if I specify host
"foo", the resolver library will search for "foo.cc.purdue.edu",
"foo.rcs.purdue.edu", and then "foo.purdue.edu" before asking the world
for "foo".

The next line is the answer to your specific question. "Options ndots:2"
says that any hostname with two or more dots (.) in it is already a FQDN
and should not go through the search list. It should be presented, as is,
for resolution.

This does mean that a request for "foo.com" (one dot) would result in
searches for foo.com.cc.purdue.edu, foo.com.rcs.purdue.edu, and
foo.com.purdue.edu before looking for plain foo.com. However,
www.foo.com triggers only one search.

The remaining "nameserver" lines are normal ones. We run a
caching, forwarding only nameserver on each busy host. Hence the
127.0.0.1 entry. The fall-back is our normal, campus-wide server.
This part is not relevant to your problems, so stay with whatever
you have.

-- 
Dale Talcott, IT Research Computing Services, Purdue University
aeh@quest.cc.purdue.edu         http://quest.cc.purdue.edu/~aeh/


Relevant Pages

  • Re: host -6 failure
    ... Subject: host -6 failure ... using an ipv4 mapped ipv6 address (which ... the second nameserver ... This causes a dns query for an IPv6 ...
    (freebsd-questions)
  • Re: host -6 failure
    ... Subject: host -6 failure ... the second nameserver in my ... My intent was to force a query to hit the ... As I said, I'm new to IPv6, but this ...
    (freebsd-questions)
  • Re: host -6 failure
    ... On Sun, Nov 9, 2008 at 3:13 AM, mdh ... using an ipv4 mapped ipv6 address (which ... the second nameserver ... fix the root problem, the other problems will go away. ...
    (freebsd-questions)
  • Re: host(1) problem with -6 option
    ... I'm having a little trouble understanding a problem that the `host` ... nameserver 127.0.0.1 ... Which is all fine and dandy when told to use IPv6: ... It makes no sense at all to try and access an IPv6 address using IPv4 transport, and trying the converse: an IPv4 address via IPv6, will either fail or try and use IPv4-mapped addresses. ...
    (freebsd-stable)
  • getaddrinfo() behavior different between XP SP2 and Vista
    ... IPv6) for my local machine. ... getaddrinfo() only returns::1 ... Ethernet adapter Local Area Connection: ... Tunnel adapter Automatic Tunneling Pseudo-Interface: ...
    (microsoft.public.win32.programmer.networks)