SaltDns. Resolver. DNS
(Salt v1.0.0)
The real resolver client: asks the recursive resolvers in
config :salt_dns, :resolvers over UDP, and again over TCP when the
answer is truncated.
config :salt_dns, :resolvers, ["9.9.9.9", "149.112.112.112"]Entries are IP literals (a string, or {address_string, port}); host names
are never accepted, so a lookup cannot depend on another lookup. Without
any entry every question is {:error, :unavailable} (the default in
development and test).
config :salt_dns, :refuse_private_resolvers, true drops resolvers whose
address is not public (SaltDns.AddressFilter), for deployments that must
not send queries into private networks. It is off by default because a
local validating resolver is a normal choice.
Each question has a deadline (config :salt_dns, SaltDns.Resolver.DNS, timeout: 2000 ms per resolver, retries: 1 further UDP attempt). Resolvers
are tried in order. A definite answer (NOERROR or NXDOMAIN) ends the
search; timeouts, SERVFAIL and REFUSED move on to the next resolver, and
the last such failure is returned. TXT lookups (the ownership challenge)
differ: see txt/1, because a negative answer may be a stale cache entry.
Replies are accepted only from the resolver's address, with the query's id and question. Recursion is requested; DNSSEC validation is the resolver's business (a bogus answer comes back as SERVFAIL).
Summary
Functions
The usable resolvers as {ip_tuple, port}, after parsing and filtering.
The serial in the SOA that the server at address (an IP literal) answers for
the zone name, asked directly with recursion off. {:error, reason} is
:timeout, :refused, :servfail or :no_answer (a reply without a SOA, or
from a server that does not serve the zone).
The TXT strings at name (the ownership challenge). A resolver may hold a
negative answer (RFC 2308) for as long as the zone's negative TTL, even after
the record exists, so "not found" is never taken from one resolver
Checks a :resolvers value: :ok, or {:error, entry} for the first entry
that is not an IP literal (or {ip, port}).
Functions
@spec resolvers() :: [{:inet.ip_address(), :inet.port_number()}]
The usable resolvers as {ip_tuple, port}, after parsing and filtering.
@spec soa_serial(String.t(), :inet.port_number(), String.t(), pos_integer()) :: {:ok, non_neg_integer()} | {:error, :timeout | :refused | :servfail | :no_answer | :unreachable}
The serial in the SOA that the server at address (an IP literal) answers for
the zone name, asked directly with recursion off. {:error, reason} is
:timeout, :refused, :servfail or :no_answer (a reply without a SOA, or
from a server that does not serve the zone).
{:error, :unreachable} is the fifth answer and is not the server's fault:
this host has no route for the address's family (no socket for it, or the
kernel says the network is unreachable). It is kept apart from :timeout so
a caller can say "not checked" instead of "no answer".
The TXT strings at name (the ownership challenge). A resolver may hold a
negative answer (RFC 2308) for as long as the zone's negative TTL, even after
the record exists, so "not found" is never taken from one resolver:
- every configured resolver is asked, in order; the first that has the record decides (a positive answer from any resolver counts);
- if none has it, the zone's authoritative servers are asked directly
(
SaltDns.Resolver.Delegation.authoritative_txt/1; their addresses come from DNS and passSaltDns.AddressFilter); a record at any of them counts, which is what ACME validation does; - only if the authoritative servers do not have it either, or cannot be
asked, is it
{:ok, []}(when at least one resolver answered), and{:error, reason}when no resolver gave an answer at all.
Checks a :resolvers value: :ok, or {:error, entry} for the first entry
that is not an IP literal (or {ip, port}).