Main Site Documentation

DHCP not working?


#1

I am having trouble getting an ip address on my netduino plus 2.
Blinky works great, so I am connectd.
The ethernet cable connected to my router has proven itself on another computer.

I am using Netmf 4.3.1, visual studio 13.
Thanks for any help.
Terrence

Here is the code.


public static void Main()
{
byte[] MAC = { 0x5C, 0x86, 0x4A, 0x00, 0xF2, 0x15 };
NetworkInterface nic = NetworkInterface.GetAllNetworkInterfaces()[0];
nic.EnableDhcp();
nic.PhysicalAddress = MAC;
Debug.Print(Network.GetNicStatus(nic));
int i = 0;
while (true)
{
	nic = NetworkInterface.GetAllNetworkInterfaces()[0];
	if (nic.IPAddress != "0.0.0.0")
		break;

	Debug.Print("Waiting for an IP Address..." + i++.ToString());
	Thread.Sleep(2000);
	Debug.Print(Network.GetNicStatus(nic));
}
}

–can’t seem to find the help section on how to post code in the forums?–


#2

Netduino Plus?

Try forum on netduino.com. You might get more help there.


#3

Well I posted it over there 24 hours ago and it hasn’t been approved. So I thought you guys could help.


#4

it might help to assign a Mac address before enabling dhcp


#5

to post code, use the square bracket CODE tags. You can hit the “101010” button above the text entry box to get a set inserted at the bottom of your reply


#6

Bret, thanks for the formatting tip.


#7

@ Mike, you are brilliant! That worked.

Thanks for that tip.

Terrence