My HA (RPi 4) is connected to router via Ethernet cable. TBH I don’t remember if HA has static IP configured (I don’t even know how to check it). For sure I have a static lease for RPi MAC address, so I suppose the IP is provided by the router’s DHCP.
During last months I noticed strange thing: restarting router (either soft or hard) makes my HA disappear from the network until RPi restart. In the past I was performing hard reset every time. But today I noticed that hassio is still being reported on router status page as available in IP v6 network.
I connected via ssh using IPv6 and executed nmcli command. It contained no ip4-related entries at all. Only IPv6 related.
Then I performed RPi reboot using ha host reboot which causes that HA retrieved its expected IP v6.
I don’t know what is happening. But disappearing from network for good just because of router restart is something not good for sure.
If you have some additional questions - feel free. I’ll do my best to help in order to fix potential issues.
Its possible you are encountering a mismatch of DHCP states between Router (DHCP Server) and RPi (DHCP Client). DHCP provides a period of time for the IP address (called a lease time), and once the time has expired the DHCP client has to renew the lease. If you reboot the router during the middle of a lease period, the router doesn’t know anything about the DHCP state of the RPI until sometime later when the lease expires and the RPi asks to renew its lease. The RPI doesn’t know anything about the router being rebooted (unless the RPI is directly connected to the router and sees its link go down and back up) and so it doesn’t know to send another DHCP request. When you reboot the RPI, at that point it will use DHCP to ask for an address, at which point both the DHCP server and client have the same state.
As for why the RPI gets an IPv6 address instead of an IPv4 address, is a bit harder to speculate, but IPv6 provides an alternative way for a device to automatically get an IPv6 address called SLAAC. So it may be that DHCP on the router is broken after restarts.
I think the best thing to do would be to set up a static IPv4 address on the RPi.
I think I know what you mean but I’m not sure I can agree. At least, mismatch you are describing would’t cause dropping the leased connection settings. there is only one case it could go this way: when querying unavailable dhcp. But why rpi even would try? exactly at the moment of the router restart? and why only ip v4?
Again: My rpi4 is connected directly to the router via ethernet cable.
If router is restarted, it may cause either disabling ethernet port for a while or not:
In the first case, client’s ethernet card will drop tcpip stack, but after reconnection it should immediately ask for dhcp lease (likely getting the same ip address)
In the second case, rpi doesn’t know that the router is being restarted. then it should keep the ip address.
In addition there is discrepancy between v4 and v6. Why it looses only ip v4?
And finally I don’t know any other device reacting on router restart like discussed rpi+hassos.
Hello,
I have the same problem. My Raspberry that hosts homeassistant is on a UPS. When there is a quick power outage, it does not shut down.
However, when the power comes back, as soon as my router restarts, the Raspberry PI does not renew the DHCP lease to get a new (or the same) address. And Homeassistant is not accessible on the network.
I see that the topic is old. How did you solve this issue ?