[ntp:questions] Best practice: re-resolve server IP address beforeeach poll/query

Per Hedeland per at hedeland.org
Thu Jun 14 20:25:23 UTC 2007

In article <46717A68.5060203 at ntp.isc.org> mayer at ntp.isc.org (Danny
Mayer) writes:
>James Cloos wrote:
>> Wolfgang> DNS refresh and expire are two SOA entities that are meant to be
>> Wolfgang> looked at by the secondaries of a domain.
>> I'm sure he was thinking of the Time To Live (TTL) values for the
>> individual RRs, rather than the values in the SOA.
>Those are of course not the ones you need to look at since those have to
> do with the zone itself and not the zone records each of which has its
>own TTL.

I think you misread... "the Time To Live (TTL) values for the individual
RRs" are of course prcisely the ones you need to look at.

>> I'm not aware of any universal way to get that at the application level,
>> using the system resolvers.

Universal it may not be, but using the res_*() functions of the ISC
resolver library (in libresolv.* or integrated into libc depending on
OS) it is of course possible to get at the TTL, since it is included in
the response packet that they provide. Here's a snippet from the DNS
component of FreeBSD's gethostbyname() implementation:

                class = _getshort(cp);
                cp += INT16SZ;                  /* class */
                if (qtype == T_A  && type == T_A)
                        _dns_ttl_ = _getlong(cp);
                cp += INT32SZ;                  /* TTL */
                n = _getshort(cp);

- that _dns_ttl_ variable is actually externally visible, i.e. available
to applications using gethostbyname(), though this is surely not
universal. (And it seems FreeBSD's getaddrinfo() implementation is
entirely disjunct from gethostby*() - it doesn't provide the TTL at all
as far as I can see.)

--Per Hedeland
per at hedeland.org

More information about the questions mailing list