How to handle dynamic IP addresses

I’m working on a plugin and am using the TCP Client. The device I’m trying to work with has a dynamic IP address and I wonder how you would handle something like that.
Right now I have a setting field for the IP address and port and set it as I go. I do know that when I lose power my IP addresses change quite often. I thought about scanning the IP address since I can enter the local network settings I’m using and see if it can find my device and store the current address. Just thinking out loud.
How do you guys do it?
Jerry

Is this a WAN or LAN address that keeps changing?

LAN: Either set the device to a staticIP, configure the router with the device’s MAC address to only issue a reserved IP.

WAN: Use a DDNS service, duckdns.org is a good (free) option if you need 5 or less addresses.

LAN and if it come to it I can set it static. I wonder how everything else works when IP addresses change. Even my connections to my Kasa devices work fine after they all change. Even my Home Remote controls work fine all the time.

Could they be getting information from Kasa’s site since I had to enter my username and password into Kasa’s device when I set it up? I don’t know what all they could pull down about my devices but maybe it’s keeping things in sync.

I have the Mac address for the device I’m playing with but I don’t know enough to know if it’s helpful. Can I connect using it instead?

The Kasa device I’m playing with is on my KasaSmart device list and continues to work so it gets updated somehow. Wonder if there is a way to pull any information from the KasaSmart device list?

I will keep on.
Jerry

In general I have found it to be good practice to put devices on Static IP’s wherever possible. You could theoretically scan all network devices on a specified subnet and obtain all MAC addresses responding - and then reverse-lookup an IP based on a known MAC. In-fact I think that is how many services already work (excluding those using multi-cast traffic). However, I would always go the StaticIP route if available.

I set it to static for now. I’m almost ashamed to say that while looking at my network I have 32 devices on it right now. I can think of four more that aren’t even turned on at the moment.

I will configure all my smart devices and security cameras for static. Yes it does make sense, I was just being lazy and really it works so good I didn’t want to screw with it.

That’s a project for another day. In your opinion should I also do our cell phones or leave them as is? and thanks for suggesting it.

Jerry

I don’t do things like cell phones as they tend to come, go, & get updated more frequently. I also tend to go the DHCP reservation route rather than Static IP’s; but either way separate documentation is critical in case you lose your configuration down the line.

I did make the change in the DCHP reservations. Cycled power to the device and it worked.

Got many more to do then I guess I’ll have to cycle the main house breaker to bring everything back up the new way.

Jerry

All devices are now configured and active with the new permanent addresses. Even got a brand new shiny spreadsheet to go with it.

Back to work on my plugin. I have something I wrote in Java that works pretty good and I have been trying to make it run right in JS. I miss the editing and debugging tools that a good Java IDE has but I am determined to get it.

Thanks,
Jerry