WIZnet Wifi Shield: Would the random assigned DHCP address from router changed?

Hereby wish to seek for your advise:

I was following this website to configure my Wifi shield as a client (connected to router) and controlled by any host that connected to router.


i notice that the router will assign a random DHCP IP address to the wifi shield at the end of the configuration. The wifi shield seems like is holding the assigned DHCP IP whenever it is connected to internet, eventhough i switch Off and On again the shield.

Hereby wish to seek for advice would the assigned IP address belongs to the wifi shield all the time? As i am afraid that another random IP will be assigned to the wifi shield again after a long time.

Many thanks!

I'm not entirely sure what you are asking, but an IP address is re-assigned every time your program asks for one in your code. You ask, the the router offers. Typically if the same device repeatedly asks for an IP, the router will be clever enough to just keep re-offering the same one, although this is not certain.

Obviously if your device is switched off, the IP expires and something else on the network asks for one, then it may be assigned the same IP your device previously had.

I don't know what device you are using for a dhcp server, but the routers I use (Mikrotik) can set a dhcp ip assignment as static. That does not mean you use a static ip in the Arduino. It means the dhcp server will issue the same ip to that client (mac address) when it requests an ip. Maybe you dhcp server has the same feature?

While agreeing with the posts above, I'd add that if your client is using DHCP to obtain its address, it would be good practice to design your overall solution on the basis that the address could change at any time. You can accommodate these changes quite easily if your client uses DNS to look up the server's current address when you need to connect to it. DHCP is really designed to work with DNS. Depending on your situation it may not be practical to access DNS and you can certainly get a working solution without it (by arranging for the DHCP address to be fixed, and configuring your clients with that fixed address) but it isn't good practice.

If you were aiming to make a completely general solution following network best practices, you'd also design your client to deal with multiple results from DNS and try each address in turn until it achieves a successful connection. (If you're ever forced kicking and screaming into running over IPv6, this will be essential.)