Articles › IoT and embedded

Your cameras and IoT devices get a new IP after every reboot. Here is the fix

Why cameras, printers and ESP32 boards come back with a new address after a power cycle, and four fixes, from a router reservation to automatic discovery.

Beginner 2 min read October 7, 2026

What you will learn
  • Devices get their IP from the router's DHCP, and it can change on a reboot or when the lease expires
  • The simplest, most reliable fix is a DHCP reservation by MAC address in the router
  • You can set a static IP on the device, but it must sit outside the range DHCP hands out
  • Systems with many devices should identify them by MAC and scan for them, not remember IPs

Systems that talk to IP cameras, 3D printers or ESP32 boards tend to break the same way. It worked yesterday; today the power blipped and the system can no longer find the device, because the device came back with a new IP while the software still remembers the old one.

Why the address changes

Most devices at home or in an office ask for an address from DHCP, which runs in the router. The router lends out addresses for a period called a lease. After a reboot, or when the lease runs out, a device may get a different address from last time, especially on a busy network.

In the router settings, find a menu called something like DHCP Reservation, Static Lease or Address Reservation, and bind the device’s MAC address to the IP you want.

You never touch the device itself, and every device is managed in one place.

Fix 2: set a static IP on the device

Most cameras and boards let you set their own address. The catch: it must be outside the range DHCP hands out, or one day the router will give the same address to something else and they will clash.

ExampleValue
DHCP range192.168.1.100 to 192.168.1.199
Range for static addresses192.168.1.10 to 192.168.1.99

On an ESP32 with Arduino:

IPAddress ip(192, 168, 1, 50);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress dns(1, 1, 1, 1);

WiFi.config(ip, gateway, subnet, dns);
WiFi.begin(ssid, password);

Fix 3: use a name instead of an IP

Many devices announce a name on the local network with mDNS, such as printer.local; an ESP32 can do it with the ESPmDNS library. Your software can then use the name instead of the address. Some networks can’t resolve these names though, for example across VLANs or on older Android phones.

Fix 4: let the system find devices itself

With many devices, or a router you can’t change, have the software remember each device by its MAC address and scan the network for its current IP whenever it can’t connect: probe the port that kind of device listens on, then match the MAC in the ARP table.

ip neigh        # Linux: IPs and MACs this machine has recently talked to
arp -a          # Windows and macOS

A good system shouldn’t break because a device changed address. Reserve addresses in the router first, and keep a scanner as the fallback for the day the router gets replaced.

Which fix to choose

  • A home or small office where you control the router: fix 1
  • You can’t change the router: fix 2, and keep a note of the ranges
  • A system you sell or install at many sites: fix 4, because you never know what the customer’s network looks like

FAQ

Where do I find the MAC address?

In the router's list of connected devices, on the sticker under the device, or in the device's app. Some devices have separate MACs for Wi-Fi and Ethernet; reserve the one you actually use.

I reserved an address, so why does the device still get a different one?

Some devices randomise their MAC address on Wi-Fi for privacy, phones especially. Turn off the Private Address or Random MAC option for that network first.

Commands and settings were tested on sample systems. Try them on a test machine before production.