Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Netduino.IP DNS resolution

Ntduino.IP DNS DHCP

  • Please log in to reply
6 replies to this topic

#1 NameOfTheDragon

NameOfTheDragon

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationCanterbury, Kent, UK

Posted 04 July 2015 - 04:46 AM

I'm trying the stack tests with Netduino.IP 1.0.0 on my Netduino Plus 2. Here's what I'm seeing in the output:

 

The thread '<No Name>' (0x2) has exited with code 0 (0x0).
Waiting for network link.
The thread '<No Name>' (0x4) has exited with code 0 (0x0).
network link is up!
ip address is configured/acquired.

*** GET NETWORK INTERFACE SETTINGS ***
Found 1 network interfaces.
ip address: 192.168.0.41

*** GET WEBPAGE ***
Resolving DNS A record for: www.netduino.com
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in Netduino.IP
ERROR: Could not resolve IP address.

*** GET TIME ***
Resolving DNS A record for: time-b.nist.gov
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in Netduino.IP
ERROR: Could not resolve IP address.
A first chance exception of type 'System.Exception' occurred in NetduinoIP_StackTests.exe
*** DONE ***

 

My network uses DHCP (in fact I have permanent reservations for all my devices so Netduino always gets the same IP address). It should also receive two DNS server addresses.

 

Now it happens that my first DNS server is currently down, due to some overnight T-storms. Netduino should however be able to fall back to the secondary DNS server, which happens to be my ADSL router. It looks like it is not doing so. These tests worked yesterday with no errors.

 

I smell a bug.

 

Regards,

Tim Long

 

 



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 July 2015 - 05:44 AM

Hi Tim,

Can you try doing a DNS lookup from your PC command line (on the same network)?

Replace 8.8.8.8 with the IP address of your primary DNS...and then the IP address of your secondary DNS.
c:\> nslookup www.netduino.com. 8.8.8.8
What do you get back, on both attempts?

Also, what values do you get if you read NetworkInterface.DnsAddresses?

Finally...what is the ErrorCode that is returned with the SocketException?

"DNS failover" is a great test; thanks for the digging, Tim.

Chris

P.S. On a more general note, regarding workarounds if DHCP-assigned DNS servers are down: one can always use a manual DNS configuration (using the special MFDeploy tool that's sticky in this forum). But for this scenario, let's dig in and figure out what's going on.

#3 NameOfTheDragon

NameOfTheDragon

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationCanterbury, Kent, UK

Posted 04 July 2015 - 10:44 PM

Here's what I found out. The problem wasn't what I thought it was. It turns out that when I flashed the new firmware, both DNS servers got set to 0.0.0.0 (as verified by MFDeploy).

 

So that sort-of explains the inability to do DNS resolution. When I fill in the correct DNS server addresses, things work again.

 

HOWEVER - I have DHCP enabled, so the DNS server addresses really should come from the DHCP response and not use the statically configured ones. I've had a cursory look at the source code (it is SO NICE having it in managed code!!) and it looks like this is supported - although from what I can make out, it isn't working as expected. If I don't enter static DNS server addresses (i.e. if they are set to 0.0.0.0 - MFDeploy won't let them be blank) then the netduino is unable to do DNS resolution and there are no DNS servers in the network interface.

 

I'm in the process of loading the debug firmware and I'll see if I can narrow it down any further.

 

Regards,

Tim



#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 05 July 2015 - 12:13 AM

Hi Tim,

Ah. I think there may be a bug in MFDeploy...where it is not setting the "get DNS servers via DHCP" flag in the ER_CONFIG sector when you enter all-zeros for the DNS servers.

The lwIP stack implementation probably interprets "0.0.0.0" as "no entry"...whereas we actually pay attention to the flags and probably pull in 0.0.0.0 as the DNS server.

If you just flashed your board (or you used the special version of MFDeploy we built with IPv6 config support) then the proper flags will be written. But if you changed the config in the standard MFDeploy...it could have reset the necessary flag.

Does that sound about right? If so, can you please post a bug report in the Netduino.IP GitHub repo (as an issue) and we'll take care of it in a firmware update? That would really be a workaround (patching the MFDeploy bug) rather than a bugfix...but it's probably the right thing to do.

Excellent sleuthing, BTW. Thank you!

Chris

#5 NameOfTheDragon

NameOfTheDragon

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationCanterbury, Kent, UK

Posted 05 July 2015 - 02:17 AM

Yeah, something odd is going on. I've stepped through the DHCP code and I can see that it is correctly receiving the DNS server addresses in the DHCP Offer. However when I try to read the DNS addresses I'm getting a NullReferenceException.

 

Checked the settings in MFDeploy and my DNS servers have reverted to 0.0.0.0 . I see no IPv6 settings so it must be the original/unpatched version, so it seems like you are on the right tracks.

 

I will raise an issue on Github.

 

--Tim



#6 NameOfTheDragon

NameOfTheDragon

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationCanterbury, Kent, UK

Posted 05 July 2015 - 03:11 AM

Issue raised.

 

FYI: even when using the new MFDeploy tool (with IPv6 settings), and even if I first program valid DNS server values, enabling DHCP and "Get DNS server addresses automatically" results in no name resolution and a NullReferenceException when attempting to read the DNS server values in managed code.

 

--Tim



#7 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 18 September 2015 - 07:24 AM

Hi Tim,

Both of the DNS issues should be fixed in the new Netduino.IP v1.0.1 release (in 4.3.2.3 firmware).

Can you grab a copy of the new firmware and let us know if these DNS issues are fully resolved for you?

Thanks for all your help testing out the new stack,

Chris





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.