vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 ? 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??? Thanks, -tony |
| |||
| 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/ |
| |||
| aeh@quest.cc.purdue.edu (Dale Talcott) wrote in message news:<aeh.1093614555@quest.cc.purdue.edu>... > 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, Thanks for your detailed answer. Unfortunately, on my AIX 5.1 system, it doesn't appear to work. BTW, we don't have IPV6 addresses yet, but I don't want to put that requirement in my code. I tried: search cnf.com options ndots:2 nameserver xxx.yyy.zzz.12 nameserver xxx.yyy.zzz.13 Then I tried the getaddrinfo() call specifying a host of "ljcqs048.cnf.com", IPV4 versions are satisfied out of the /etc/hosts file, but there are two querys made to the nameserver: ljcqs048.cnf.com for a type AAAA ljcqs048.cnf.com.cnf.com for a type AAAA So, "ndots:2" doesn't seem to work. What works "partially", is leaving resolv.conf as it was originally: domain cnf.com nameserver xxx.yyy.zzz.12 nameserver xxx.yyy.zzz.13 And changing /etc/netsvc.conf to what you suggested: hosts = local4 , bind4 I say "partially", because there is no query for "ljcqs048.cnf.com.cnf.com", but there IS a nameserver query for a type A record for "ljcqs048.cnf.com" ....i.e. an IPV4 address...but IPV4 addresses should have been satisfied out of the /etc/hosts file. ??? Thanks again for your help. -tony |
| |||
| 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". > No, you need to enter "hosts=local=auth,bind" to inform the resolver logic that the local hosts file is authoratitive, else it will keep checking sources in the chain until either it's asked everybody, or someone has given an authoratitive answer. There's also an env var you can set to get this behavior, but I can't remember what it is right now. > How do I create the same behaviour for IPV6 addresses ? > > 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??? > > Thanks, > -tony Sorry, I'm on airplane just now and can't check, but IIRC , you need to terminate the request string with a period '.', to prevent the resolver logic from trying all the domains you have specified in the /etc/"blah blah blah" file. -- #include <disclaimer.std> /* I don't speak for IBM ... */ /* Heck, I don't even speak for myself */ /* Don't believe me ? Ask my wife :-) */ Richard D. Latham lathamr@us.ibm.com |
| ||||
| lathamr@us.ibm.com (Richard D. Latham) wrote in message news:<acwg5k3r.fsf@us.ibm.com>... > 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". > > > > No, you need to enter "hosts=local=auth,bind" to inform the resolver > logic that the local hosts file is authoratitive, else it will keep > checking sources in the chain until either it's asked everybody, or > someone has given an authoratitive answer. > > There's also an env var you can set to get this behavior, but I can't > remember what it is right now. > > > > How do I create the same behaviour for IPV6 addresses ? > > > > 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??? > > > > Thanks, > > -tony > > Sorry, I'm on airplane just now and can't check, but IIRC , you need > to terminate the request string with a period '.', to prevent the > resolver logic from trying all the domains you have specified in the > /etc/"blah blah blah" file. Richard, I've tried the following netsvc.conf definitions with the corresponding results: With resolv.conf containing only domain and nameserver lines: netsvc.conf Format Nameserver Queries hosts=local=auth,bind AAAA XXX.YYY.COM AAAA XXX.YYY.COM.YYY.COM hosts=local=auth,bind4 - No QUERY - It appears the problem has been solved. Thanks goes out to Richard Latham and Dale Talcott. -tony |