Anyone know how to find the TTL for a DNS record with :inet?

I’m learning my way around :inet and :inet_res to perform DNS lookups but the documentation is a little confusing. Getting the value for the records themselves is straightforward enough, but I can’t figure out how to find the TTL values for each of the records.

Anybody ever figure this out?

1 Like

:inet_res.resolve should give you the TTL for each record it returns.
For example, in:

iex(1)> :inet_res.resolve('', :in, :a)

 {:dns_rec, {:dns_header, 1, true, :query, false, false, true, true, false, 0},
  [{:dns_query, '', :a, :in}],
    {:dns_rr, '', :a, :in, 0, 28537, {78, 46, 110, 60},
     :undefined, [], false}
  ], [], []}}

28537 is the TTL


Thank you! I was trying to figure it out with lookup.

1 Like