home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.91k stars 30.98k forks source link

IPv6 not updating #129555

Open Switch123456789 opened 3 weeks ago

Switch123456789 commented 3 weeks ago

The problem

IPv4 gets updated just fine, however IPv6 remains unchanged despite homeassistant having a working IPv6 connection.

What version of Home Assistant Core has the issue?

core-2024.10.2

What type of installation are you running?

Home Assistant OS

Integration causing the issue

no_ip

Link to integration documentation on our website

https://www.home-assistant.io/integrations/no_ip

Diagnostics information

DEBUG (MainThread) [homeassistant.components.no_ip] Updating NO-IP success: my.domain.name

Example YAML snippet

no_ip:
  domain: "my.domain.name"
  username: "myname"
  password: "mypassword"
  timeout: 60
home-assistant[bot] commented 3 weeks ago

no_ip documentation no_ip source

Switch123456789 commented 2 weeks ago

I checked the code and it seems like the integration doesn't send the IP and rather relies on No-IP's Webserver to gather the IP from the HTTP-request. In return the IP-version that gets updated is the one that the integration gets from the set DNS-server. It seems like this is IPv4 by default. I wonder what happens if I disable IPv4 in Home Assistant, unfortunately I can't do that safely atm.

Switch123456789 commented 1 week ago

I found a decent workaround for now: I created sensors that retrieve the IP's every full hour via a command_line. Whenever an IP changes, a template gets triggered that will execute a rest_command using ddns_url from the secrets.yaml as url.

# secrets.yaml
ddns_url: "https://NAME:PASS@dynupdate.no-ip.com/nic/update?hostname=HOST&myip={{ states('sensor.ipv4'),{ states('sensor.ipv6') }}"

# configuration.yaml
command_line:
  - sensor:
      name: "IPv4"
      command: "curl -4 ifconfig.co"
      scan_interval: 3600
  - sensor:
      name: "IPv6"
      command: "curl -6 ifconfig.co"
      scan_interval: 3600

template:
  - trigger:
      - trigger: state
        entity_id:
          - sensor.ipv4
          - sensor.ipv6
    action:
      - delay:
          seconds: 2
      - action: rest_command.ip_update

rest_command:
  ip_update:
    url: !secret ddns_url
    method: post

For those who are looking for a quick and easy solution, copy and paste this into your configuration.yaml/secrets.yaml and adjust NAME, PASS & HOST. After a restart the IP should be updated successfull.