getaddrinfo and TTL

Phil Mayers p.mayers at imperial.ac.uk
Sat Aug 4 12:03:47 UTC 2012


On 08/03/2012 05:48 PM, Martin McCormick wrote:
> 	Can one read the TTL for a given lookup in
> getaddrinfo?

I don't believe so.

>
> 	Better yet, is there a listing of the entire range of
> values one can read from all the structures?

The getaddrinfo() interface is specified in RFC 3493.

Specific platforms might extend the "struct addrinfo" (maybe?) but AFAIK 
most / all implementations just conform to the basic RFC.

>
> 	I wrote an application years ago to let us change the
> name of a host. The old code uses zone transfer to pull in the
> whole zone, actually several zones in to a pile of A records. We
> look for the old name, replace it with the new name and then do
> a delete and add.

I don't understand this I'm afraid.

>
> 	If getaddrinfo contains this value, the replace
> application can run much faster, just doing one lookup, and the
> new record we write back will keep whatever value we originally
> had.

If you want TTL, you will need to use DNS-specific functions like the 
res_* API. You need to be sure you are querying the master, otherwise 
the TTL will be the one from cache, not the "real" value.



More information about the bind-users mailing list