DNS (dns v2.2.0)
Link to this section Summary
Link to this section Functions
Link to this function
query(domain, type \\ :a, dns_server \\ {"8.8.8.8", 53}, proto \\ :udp)
Specs
query(String.t(), atom(), {String.t(), :inet.port()}, :tcp | :udp) :: DNS.Record.t()
Queries the DNS server and returns the result
Examples:
iex> DNS.query("tungdao.com") # <= Queries for A records
iex> DNS.query("tungdao.com", :mx) # <= Queries for the MX records
iex> DNS.query("tungdao.com", :a, { "208.67.220.220", 53}) # <= Queries for A records, using OpenDNS
iex> DNS.query("tungdao.com", :a, { "208.67.220.220", 53}, :tcp) # <= Queries for A records, using OpenDNS, with TCP
Link to this function
resolve(domain, type \\ :a, dns_server \\ {"8.8.8.8", 53}, proto \\ :udp)
Specs
resolve(String.t(), atom(), {String.t(), :inet.port()}, :tcp | :udp) :: {atom(), :inet.ip()} | {atom(), list()} | {atom(), atom()}
Resolves the answer for a DNS query
Example:
iex> DNS.resolve("tungdao.com") # {:ok, [{1, 1, 1, 1}]}
iex> DNS.resolve("tungdao.com", :txt) # {:ok, [['v=spf1 a mx ~all']]}
iex> DNS.resolve("tungdao.com", :a, {"8.8.8.8", 53}) # {:ok, [{1, 1, 1, 1}]}
iex> DNS.resolve("tungdao.com", :a, {"8.8.8.8", 53}, :tcp) # {:ok, [{1, 1, 1, 1}]}