Does HomeAssistant need stable IP addresses for devices?

I’m wondering how people with HomeAssistant are managing the IP address for all of their IOT devices?

The options that I’m aware of are:

  • Static IP Addresses - You manually set a static IP address on each device. This doesn’t really scale, and is vulnerable to human error (e.g. address conflict on two devices)
  • DHCP - The devices grab IP addresses from a pool - however, the address may change between reboots, lease timeouts etc.
  • DHCP with static reservations - On your DHCP server, you reserver specific IP addresses from the pool for devices via MAC addresses. It’s a bit of overhead though.

Let’s say you have a mix of IOT devices (some of this is planned in my case):

  • ESPHome devices
  • Shelly devices
  • Tuya devices (used via localtuya or tuya-local - still figuring out which is better)
  • WLED light controllers

In my case, the router is running VyOS, and it’s a dual-stack IPv4/IPv6 network.

VyOS does allow setting static DHCP leases:

https://docs.vyos.io/en/1.4/configuration/service/dhcp-server.html#static-mappings

However, it’s a bit of a pain having to manage that manually. The Ansible module for VyOS doesn’t seem to support configuring the DHCP server either:

https://docs.ansible.com/projects/ansible/latest/collections/vyos/vyos/index.html

so you can’t even use that to streamline things, or get it into source control :confused:.

However, these days - do you actually need stable address for devices? (i.e. with mDNS/Bonjour, and all that?)

As in, will HomeAssistant handle it fine, if device IP addresses change underneath it? Or what would you do to handle this?

Depends on the device, and protocol.

Larger microcontrollers have memory and flash to implement protocols like DNS and mDNS. Others don’t - e.g. Tasmota can use mDNS to lookup the IPv4/IPv6 of a MQTT server, but by default doesn’t so it’s IPv4 only.

There were bugs in the HA implementation of a MQTT broker which broke IPv6, so I’ve never tried it again:

Note the GitHub issue comment (which could be out of date now):
https://github.com/home-assistant/core/issues/70163#issuecomment-1117155311


“do you need stable IPv4?” - unless you test it, my default answer is YES!

If this helps, :heart: this post!

I don’t understand why anyone would ever want ipv6 on a LAN. On WAN I understand why, but on LAN?

Discovery protocols is the usual tool, like mDNS, SSDP, uPNP and ZeroConfig to mention some of the open ones, but some devices also use proprietary discovery protocols.

I would prefer an IPv6 only LAN any day over an IPv4.
Just the advantage of getting rid of NAT is enough to justify it.

3 Likes

100% yes.

ALL problems are name resolution issues until proven otherwise… Period.

Pick one that works stick with it.

I use reservations in my UI gear.

2 Likes

I use local DNS records, defined in my router, and avoid IP addresses whenever I can.

For ESP Home I had to add the used domain in the devices WiFi config

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  domain: !secret network_domain

Shelly works with local DNS records out of the box.
All my MQTT devices also work out of the box.

Generally, yes. Other than my network equipment and a few devices, everything in my setup just uses DHCP and is fine.

mDNS Caches on i.e smaller Device, Is Small, and TTL very short, beside “shit happens” in all Topologies
LAN NIC’s communities over their IP Numbers , Minimizing their “usage/effort” is always an “optimizing” approach ( Host Names is just a “Help” for Humans ! )

I Always Connect to my HA, Laptops, PC’s With their IP(Not Names), whether it’s from a browser or consoles/apps of various kinds
And Yes, ALL My IP Devices, have “dedicated” IP Numbers( within the DHCP-Scope ), I Deside Which IP Number every Device Will Have, So i know quite fairly which i.e Brand/Device it is when seeing an IP-Number in i.e logs etc
( I Know … Knowledge For Nerds :joy: )

Your first and third options you have given are basically the same thing.
Letting your router manage IP addresses at random (the dynamic in DHCP) and then asking for your system to go and search for them is a bit inefficient and has overheads and often issues that neophytes stumble over. Who’s in control? You, or it? Consistency, reliability, guesswork, randomness - pick two.
How many IPv4 addresses can you issue on your LAN for one /24 segment? Go on, look it up. Manageable with a paper list or spreadsheet? If you need more, then IPv6 is there, and has been there for decades, to supply the need. I read somewhere there were enough IPv6 addresses for every two atoms in the universe - you won’t run out soon!
There are many valid reasons why having a fixed IPv6 address may not be a desirable thing, especially if you have something to hide, or protect yourself from. A sustained DDOS on your dedicated IPv6 Address is not something to be sneezed at - you cannot just turn off your router for a few minutes and get a new address like a lot of people can with IPv4 and NAT.
A little more reading on basic networking will bring some clarity to your search for knowledge.

Not at all.
DHCP with a reserved IP will still request an IP address from the DHCP server, so if the DHCP server is unavailable the. It will fail.

With a 10.0.0.0/8 network you should have enough even with IPv4.

2 Likes

RARELY! You do not need static IP addresses.
On my network I have more than 100 IP clients, and only one has a static IP, my router. (Managing over 100 IP addresses would quickly get out of control). My cameras and servers all have reserved IP addresses in the router. The camera IP’s are reserved only because their IP is hard-coded in Go2RTC (inside Frigate). Servers have reserved IP addresses for similar reasons. For example when you configure Samba Share in Home Assistant you have to provide the IP address of the server you are connecting to. If that server were on DHCP assignment you run the risk of the server IP changing.

Reserved addresses in your DHCP router are not static IP’s.