[rbldnsd] AAAA Queries?

Steven F Siirila sfs at tc.umn.edu
Fri Jul 28 21:41:33 MSD 2006


We are currently using this snippet to query DNSbls.
We do not yet run IPv6 though, so it shouldn't be an issue anyways.

#define UC(b)   (((int)b) & 0xff)       /* converts char to int (0-255) */

/*
 * dnsbl - read DNS block list data
 */
struct hostent *
dnsbl(char *domain, in_addr_t ipaddr)
{
    char *cp;                           /* general purpose */
    char hbuf[MAXHOSTNAMELEN];          /* temporary host name buffer */
    struct hostent *hp;                 /* host node pointer */

    cp = (char *)&ipaddr;
    sprintf(hbuf, "%d.%d.%d.%d.%s",
            UC(cp[3]), UC(cp[2]), UC(cp[1]), UC(cp[0]), domain);
    if (debug) {
        errmsg("Querying %s", hbuf);
    }
    if ((hp = gethostbyname(hbuf)) == NULL && h_errno == TRY_AGAIN) {
        errmsg("Temporary error querying %s", domain);
    }
    return(hp);
}


On Fri, Jul 28, 2006 at 09:25:35PM +0400, Michael Tokarev wrote:
> Victor Duchovni wrote:
> > On Fri, Jul 28, 2006 at 09:42:26AM -0400, Bri Bruns wrote:
> > 
> >> Here's whats going on, and its very simple.  On machines with IPv6 
> >> enabled and functioning, for example, a Linux box, the resolver queries 
> >> go by default AAAA lookup, then a normal A lookup.  I can't remember 
> >> why - I think it has something to do with an IPv6 related RFC, where 
> >> IPv6 is supposed to be tried first before IPv4 unless the resolver 
> >> library is explicitly told to do so otherwise.
> > 
> > True for getaddrinfo(), but RBL lookups are not usually made from the
> > C-library getaddrinfo() routine. Rather RBL aware software makes
> > explicit DNS "T_A" lookups. If somebody writes broken RBL lookup
> > software that uses getaddrinfo() they need to be sent off for
> > "re-education"...
> 
> Well.  This stuff isn't this simple.
> It's trivial to write
> 
>   if (getaddrinfo(sprintf(..., ipaddr, dnsbl))) {
>      ...
>   }
> 
> but it's *far* more complex to write a DNS client, even
> this simple one (I know because I did ;)
> 
> So "re-education" isn't quite a right word here.  More,
> that getaddrinfo() version works, works right away (yes,
> it's still not complete, because we don't have TXT records).
> 
> Ditto for perl code for the same task.  gethostbyname() is
> here in standard install, but DNS-related things are huge
> slow monsters with difficult-to-use interface.
> 
> /mjt
> _______________________________________________
> rbldnsd mailing list
> rbldnsd at corpit.ru
> http://www.corpit.ru/mailman/listinfo/rbldnsd

-- 

Steven F. Siirila			Office: Lind Hall, Room 130B
Internet Services			E-mail: sfs at umn.edu
Office of Information Technology	Voice: (612) 626-0244
University of Minnesota			Fax: (612) 626-7593


More information about the rbldnsd mailing list