[erlang-questions] inet_res:getbyname/2 and udp:connect/3

Tony Rogvall tony@REDACTED
Wed Jun 16 15:17:07 CEST 2010


On 16 jun 2010, at 14.47, Dmitry Belyaev wrote:

> Try to add one working nameserver after 127.0.0.1 like this (like for my router):
> 
> inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{127,0,0,1},53}, {{192,168,0,1},53}]},verbose], 5000).
> 
> Even if second server is working, the result will be the same.
> 
> Dmitry Belyaev
> 

In may case it works, are you sure your router is on 192.168.0.1, mine is on 192.168.0.254
Also the router must support DNS forwarding.

My output:

inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{127,0,0,1},53},{{192,168,0,254},53}]},verbose], 1000).
Query: {msg,[{header,{header,[{id,14},
                              {qr,0},
                              {opcode,'query'},
                              {aa,0},
                              {tc,0},
                              {rd,true},
                              {ra,0},
                              {pr,0},
                              {rcode,0}]}},
             {qdlist,[{dns_query,[{domain,"www.rogvall.se"},
                                  {type,a},
                                  {class,in}]}]},
             {anlist,[]},
             {nslist,[]},
             {arlist,[]}]}
Try UDP server : {127,0,0,1}:53 (timeout=666)
UDP server error: {error,econnrefused}
Try UDP server : {192,168,0,254}:53 (timeout=666)
Got reply: {msg,[{header,{header,[{id,14},
                                  {qr,true},
                                  {opcode,'query'},
                                  {aa,false},
                                  {tc,false},
                                  {rd,true},
                                  {ra,true},
                                  {pr,false},
                                  {rcode,0}]}},
                 {qdlist,[{dns_query,[{domain,"www.rogvall.se"},
                                      {type,a},
                                      {class,in}]}]},
                 {anlist,[{rr,[{domain,"www.rogvall.se"},
                               {type,cname},
                               {class,in},
                               {ttl,20410},
                               {data,"rogvall.se"}]},
                          {rr,[{domain,"rogvall.se"},
                               {type,a},
                               {class,in},
                               {ttl,20410},
                               {data,{85,112,160,12}}]}]},
                 {nslist,[{rr,[{domain,"rogvall.se"},
                               {type,ns},
                               {class,in},
                               {ttl,85210},
                               {data,"ns02.netcamp.se"}]},
                          {rr,[{domain,"rogvall.se"},
                               {type,ns},
                               {class,in},
                               {ttl,85210},
                               {data,"ns01.netcamp.se"}]},
                          {rr,[{domain,"rogvall.se"},
                               {type,ns},
                               {class,in},
                               {ttl,85210},
                               {data,"ns03.netcamp.se"}]}]},
                 {arlist,[{rr,[{domain,"ns01.netcamp.se"},
                               {type,a},
                               {class,in},
                               {ttl,1343},
                               {data,{85,112,160,6}}]},
                          {rr,[{domain,"ns03.netcamp.se"},
                               {type,a},
                               {class,in},
                               {ttl,1343},
                               {data,{85,112,162,6}}]}]}]}
{ok,{dns_rec,{dns_header,14,true,'query',false,false,true,
                         true,false,0},
             [{dns_query,"www.rogvall.se",a,in}],
             [{dns_rr,"www.rogvall.se",cname,in,0,20410,"rogvall.se",
                      undefined,[],false},
              {dns_rr,"rogvall.se",a,in,0,20410,
                      {85,112,160,12},
                      undefined,[],false}],
             [{dns_rr,"rogvall.se",ns,in,0,85210,"ns02.netcamp.se",
                      undefined,[],false},
              {dns_rr,"rogvall.se",ns,in,0,85210,"ns01.netcamp.se",
                      undefined,[],false},
              {dns_rr,"rogvall.se",ns,in,0,85210,"ns03.netcamp.se",
                      undefined,[],false}],
             [{dns_rr,"ns01.netcamp.se",a,in,0,1343,
                      {85,112,160,6},
                      undefined,[],false},
              {dns_rr,"ns03.netcamp.se",a,in,0,1343,
                      {85,112,162,6},
                      undefined,[],false}]}}

/Tony





More information about the erlang-questions mailing list