Main Site Documentation

Why does show up in NetworkInterface.DnsAddresses?


Consider the following code:

var interfaces = NetworkInterface.GetAllNetworkInterfaces();
if (!interfaces[0].IsDhcpEnabled) {
} else {    

for (int i = 0; i < interfaces[0].DnsAddresses.Length; i++) {
    Debug.Print("DNS Server " + i + ": " + interfaces[0].DnsAddresses[i]);

The following will be printed out:

DNS Server 0:
DNS Server 1:

I am pretty sure that my router is not giving out Certainly the workstations on my network don’t list this address. Where is it coming from?

Occasionally, when I try to resolve a DNS address with Dns.GetHostEntry(), it will fail with a SocketException.

FYI-- in MFDeploy, my Cobra reports:
ClrInfo.targetFrameworkVersion: 4.0.1681.0


I suspect the first DNS address is your router. The second is the DNS address that you router gave you was on that it got via DHCP from your IP provider.

You should also check the network configuration via MFDeploy.


Yep, is my router, but is not the one it got from my ISP. That doesn’t even point to a host (it ends with .0).

I’m extremely new to the .NET micro framework, but I went to MFDeploy > Target > Configuration > Network and updated my network settings. I changed the Secondary DNS Server to both and These values seem to get saved even if I power-cycle the board.

However, when I run the code from my original post, it still prints out !


Could please try it with another network with different DHCP server? Do you get the same weired IP address?


I don’t have another router handy, but when I look at the DHCP exchange in Wireshark, I can confirm that is the only address offered by the router.

When I do a google search for, the first result is a post on the GHI Electronics forums that mentions the same IP address. Something makes me doubt that is coincidence… :slight_smile:


Maybe it is somethin deep in the Microsoft code :smiley:

Some fallback adresses or or a DNS server in the MS interanl network for debugging :whistle:


I must say, this is very very interesting :o


Might it have anything to do with the fact that my router only gives out 1 DNS server address?

However, I must say that I’ve never had ANY issue with any other device on my network, wired or wireless.


That should be it I think


Still, I would think that a “default” address should not be filled in, when one is not supplied in the DHCP exchange. Greg, don’t suppose you caught what happened when your DNS lookup failed, did it fail over to the 2nd DNS server by any chance?


Brett, I agree-- this seems like a bug. I am going to have to do more testing before I can verify, for sure, that the extra DNS error caused my lookups to fail.

However, it was some exceptions (SocketException, I think) that caused me to look into all this in the first place anyway.

I should a test application ready soon to see if my network calls actually fail because of the DNS configuration.


It seems that your DHCP server is not providing a secondary DNS IP address, but the system should set it to I suppose.We will look into this issue more.
But you should keep something in mind, if the first DNS was correct, the system will not communicate the secondary DNS, (which is the valid case in most times).

And in your specific case, you already have only one DNS IP address with your DHCP server. so you will get the same results with or as a secondary DNS.



I’m also trying to use the following code on my Chipworkx :

var interfaces = NetworkInterface.GetAllNetworkInterfaces();
if (!interfaces[0].IsDhcpEnabled)

But the RenewDhcpLease throw me an Exception after a while (that seems to be a time out…
DHCP has been set with MFDEPLOY, and when I ask the NetworkInterface boot configuration, it show me :

IP :
no DNS

Which are effectively the params I entered in MFDeploy. Does it mean that something goes wrong with the way I’m trying to use it ?

Is dynamic DNS disabled ?

Thanks for your feedback.



you better start a new topic since your question is not related to the original question.
And, use code tags when posting code please.


OK, I open a new topic…