ioangogo
(Ioan Loosley)
October 10, 2022, 9:36pm
1
In the network settings of home assistant OS there are 3 configuration options for IPv6, Automatic, Static and off. when running a network without DHCPv6(for reasons) this makes letting severs have shorter addresses a little more annoying.
Linux does support a Draft RFC for a user configured host token, so that it still gets prefixes from a RA, but it can have a manually assigned host segment.
Under NetworkManager this is configured using
[ipv6]
token=::420
which would combine with a prefix of 2001:db80:2894::/32
to become 2001:db80:2894::420
I’d suggest careful testing with IPv6 and HASS after finding weird issues with MQTT:
opened 06:15PM - 16 Apr 22 UTC
closed 11:13AM - 04 May 22 UTC
integration: mqtt
### The problem
HASS Mosquitto only works with IPv4, with IPv6 connections cont… inually reporting `Socket error on client <unknown>, disconnecting.` in the logs, and connections rejected.
Forcing clients to connect via IPv4 works immediately (e.g. not auth, MQTT, nor integration settings).
Expect label `integration: mqtt`
### What version of Home Assistant Core has the issue?
core-2022.4.4
### What was the last working version of Home Assistant Core?
_No response_
### What type of installation are you running?
Home Assistant OS
### Integration causing the issue
Mosquitto MQTT broker add-in
### Link to integration documentation on our website
https://github.com/home-assistant/addons/blob/master/mosquitto/DOCS.md
### Diagnostics information
# HASS MQTT Mosquitto
HASS Mosquitto only works with IPv4, with IPv6 connections continually reporting `Socket error on client <unknown>, disconnecting.` in the logs, and connections rejected. Forcing IPv4 works immediately (e.g. not auth, MQTT, nor integration settings).
## Environment
* BT VDSL router serving DHCP, DNS with `*.local` internal domain names.
* The router offers both IPv4 and IPv6 addresses, with a preference for IPv6.
* HASS running on a RPi3:
* Core core-2022.4.4
* Mosquitto add-in v6.0.1
* Tasmota integration
* MQTT integration
* Several devices running Tasmota 11, migrating from `Set Option 19 1` to `Set Option 19 0` to move from MQTT Discovery, to the dedicated Tasmota add-in.
(As temperature sensors discovered via MQTT lack the additional `state_class:` config, which prevents long-term graphing. The Tasmota integration works).
* A test laptop running Fedora 35, `mosquitto_pub`, with both IPv4 and IPv6 stacks.
## Steps to reproduce
### IPv6 fails - `Socket error`
* Connect from a test laptop to HASS running mosquitto.
* The initial config used a hostname for the HASS server, which the router DNS resolved to an IPv6 record.
* Socket error in the Mosquitto log, no connection on the client
```
# Fails
mosquitto_sub -d -i "monitor" -h homeassistant.home --username 'tasmota' --pw 'secret' -v -t '#'
# Server log:
1650115240: New connection from 192.168.1.10 on port 1883.
1650115240: Socket error on client <unknown>, disconnecting.
1650115240: New connection from 192.168.1.20 on port 1883.
1650115240: Socket error on client <unknown>, disconnecting.
```
### IPv4 works
* Change the `mosquitto_sub` command line from a hostname to the explicit IPv4 address of the HASS server.
* `mosquitto_sub` connects immediately without issue.
```
# works
mosquitto_sub -d -i "monitor" -h 192.168.1.50 --username 'tasmota' --pw 'secret' -v -t '#'
Client monitor sending CONNECT
Client monitor received CONNACK (0)
Client monitor sending SUBSCRIBE (Mid: 1, Topic: #, QoS: 0, Options: 0x00)
Client monitor received SUBACK
Subscribed (mid: 1): 0
# Server log:
New connection from x - not captured properly.
```
## Network diagnostic test
### Telnet IPv6 test - FAILS
Does not connect:
```
$ telnet homeassistant.home 1883
Trying 2a00:[IPv6 address]...
^C
```
#### Telnet IPv4 Test - WORKS
Connects immediately:
```
$ telnet -4 homeassistant.home 1883
Trying 192.168.1.50...
Connected to homeassistant.home.
Escape character is '^]'.
```
### Example YAML snippet
_No response_
### Anything in the logs that might be useful for us?
```txt
See the Diagnostics information for environment, and steps to reproduce.
All IP addresses and hostnames have been sanitised - no useful data should have been removed.
* 192.168.1.10 - Sonoff with DS18B20, Tasmota 11.
* 192.168.1.20 - Fedora 35 laptop with mosquitto client
* 192.168.1.50 - HASS on a RPi3b, hostname `homeassistant.home` (assigned by a BT VDSL hub running DHCP and DNS - hence not `*.local` and a preference for IPv6 AAAA)
```
### Additional information
I found the issue trying to fix MQTT whilst switching from MQTT Discovery, to the dedicated Tasmota add-in.
The config (Tasmota clients and HASS Mosquitto) worked fine, until re-installing the Mosquitto add-in triggered a config change.
Note: Tasmota temperature sensors discovered via MQTT lack the additional `state_class:` config, which prevents long-term graphing. The Tasmota integration works great and adds in the metadata. Installing the extra integration and migrating Tasmota 11 from `Set Option 19 1` to `Set Option 19 0` to use Tasmota add-in now works very well.
ioangogo
(Ioan Loosley)
October 10, 2022, 11:32pm
3
that is unrelated to this feature reqest, although i agree should be fixed
did you open the issue in the correct repo like one of the comments suggested?
wmaker
(Tommy Long)
October 13, 2022, 7:01pm
4
Thanks for the info, I didn’t know about tokenizing an ipv6 interface identifier .
Just as a confirmation, I was able to configure it (and unconfigure it) using nmcli on HassOS. Note: there is a dependency between addr-gen-mode
and token
.
# nmcli con mod "Supervisor enp0s3" ipv6.addr-gen-mode eui64
# nmcli con mod "Supervisor enp0s3" ipv6.token ::420
to go back to what it was before:
# nmcli con mod "Supervisor enp0s3" ipv6.token ''
# nmcli con mod "Supervisor enp0s3" ipv6.addr-gen-mode stable-privacy