m4hi2

m4hi2

Can not resolve IP from the DNS provider of my choice

Hello,

I’m trying to create a service to watch DNS record changes through multiple DNS providers like Google, CF, Q9, etc. I needed a function/module to query my resolver of choice for this. I stumbled onto :inet_res.resolve/4 but I’m having difficulties providing it the :nameservers option.

When I do, :inet_res.resolve(~c"google.com", :in, :a, []) or :inet_res.resolve(~c"google.com", :in, :a, [{:verbose, true}]) it works. But whenever I try to pass,

opts = [
  {:nameservers, nameservers},
  {:verbose, true}
]

I get the following error:

** (ArgumentError) argument error
    (kernel 10.0) inet_res.erl:557: :inet_res.make_options([nameservers: [{1, 1, 1, 1}], verbose: true], [:nameservers, :nxdomain_reply, :recurse, :retry, :servfail_retry_timeout, :timeout, :udp_payload_size, :usevc, :verbose])
    (kernel 10.0) inet_res.erl:565: :inet_res.make_options/2
    (kernel 10.0) inet_res.erl:555: :inet_res.make_options/2
    (kernel 10.0) inet_res.erl:539: :inet_res.make_options/1
    (kernel 10.0) inet_res.erl:940: :inet_res.make_query/4
    (kernel 10.0) inet_res.erl:916: :inet_res.res_query/5
    (kernel 10.0) inet_res.erl:346: :inet_res.resolve/5
    #cell:xnk2qwn5ih4huzqe:8: (file)

Here is the code snippet that I’m playing with:

nameservers = [{1, 1, 1, 1}] # 1.1.1.1 is Cloudflare's DNS

opts = [
  {:nameservers, nameservers},
  {:verbose, true}
]

:inet_res.resolve(~c"google.com", :in, :a, opts, 5000)

Elixir Version info:

iex --version
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

IEx 1.17.2 (compiled with Erlang/OTP 27)

Any clues as to why this is not working? Thanks!

Marked As Solved

D4no0

D4no0

If you look at the nameserver type, you will see that it is:

-type nameserver() :: {inet:ip_address(), Port :: 1..65535}.

So you will have to define your opts accordingly:

# This assumes cloudflare nameserver receives requests on port 853
opts = [
  nameservers: [{{1, 1, 1, 1}, 853}],
  verbose: true
]

Where Next?

Popular in Questions Top

JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
logicmason
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement