Main Site Documentation

How to Redetecting the new Dynamic IP Address?


#1

Hello,
I have a situation and i’m not sure how to handle it…
basically I have a Cerbuino and ENC28J, attached to a router, using Dynamic IP address… at first start the board returns the actual IPAddress throught the following code:


IPAddress.GetDefaultLocalAddress();

now if I restart the router or renew the IPAddress from the router to the board, somehow the board keeps returning the old address… and I have no way in code of finding out the new address unless I reset the board…

Does anyone know of an efficient NETMF code to get the actual IPAddress even when renewed?

thanks.


#2

Generally, DNS will assign you the same IP address if renew or ask for a new address within a short time period. The IP address is associated with you MAC address, and if DNS has your MAC address in it cache, it will assign you the same IP address.


#3

Thanks Mike, but what i’m saying is I forced my DNS to assign the board another address and for some reason the Code above never shows the newly assigned address, and keeps displaying the old address, is there a reliable way to detect the change.
and btw this event never fires:


 NetworkChange.NetworkAddressChanged 

so is this a bug ?


#4

@ Jay Jay - I suspect what is happening, after the device discovers the DNS server, and sees that it is on the same sub-net when it got its last IP address, is asking for that address again. The DHCP server, having no assignment for that address, is assigning the requested address.


#5

Network monitor. Check if the DHCP requests are ever made. Make sure the link between the DHCP issued address and what the board uses is correct.