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

Danny Mayer mayer at ntp.isc.org
Fri Jun 15 02:34:17 UTC 2007

Per Hedeland wrote:
> 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.

That's what I said.

>>> 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);

gethostbyname() only supports IPv4 so it's not acceptable. It's been a
long time since I looked at the res_*() functions since we don't use
them in BIND 9 even though they are built on Unix platforms if you want it.

> - 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.)

That's probably because it was a complete redesign. TTL is usually only
relevant for nameservers, applications are expected to just make the
requests and let the resolver worry about that level of detail.


> --Per Hedeland
> per at hedeland.org

More information about the questions mailing list