DNS (dns v2.3.0) View Source

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)

View Source

Specs

query(String.t(), atom(), {String.t(), :inet.port()}, :tcp | :udp) ::
  DNS.Record.t()

Queries the DNS server and returns the result.

Examples

Queries for A records:

iex> DNS.query("tungdao.com")

Queries for the MX records:

iex> DNS.query("tungdao.com", :mx)

Queries for A records, using OpenDNS:

iex> DNS.query("tungdao.com", :a, { "208.67.220.220", 53})

Queries for A records, using OpenDNS, with TCP:

iex> DNS.query("tungdao.com", :a, { "208.67.220.220", 53}, :tcp)
Link to this function

resolve(domain, type \\ :a, dns_server \\ {"8.8.8.8", 53}, proto \\ :udp)

View Source

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.

Examples

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}]}