I recently had a full outage of IPv6 on my Deutsche Glasfaser fibre-based internet line that lasted for more than 3.5 months. I only found out by chance, which I found very frustrating. If it happens again I want to be notified immediately, so I built an automation that has the following architecture:
- OpenWrt-based router/internet gateway sends event every time WAN interface changes with respect to IPv6
- Event lands in an MQTT broker
- Home Assistant: set up sensor based on messages sent to MQTT topic
- Home Assistant: set up automation if IPv6 status sensor changes to “broken”
Here’s the details:
First we need events to be generated if and when the status of our WAN interface (more specifically the IPv6-specific interface named wan6) changes. We can easily and elegantly accomplish this by using the “Hotplug” mechanism built into Linux and OpenWrt. I had to write a script that parses the IPv6 status on changes of the wan6 interface and determines the IPv6 assignment and delegation of a prefix. If these are not available, then the status is “unhealthy.”
Here’s my script which I deployed as /etc/hotplug.d/iface/99-ipv6-monitor:
