esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
407 stars 26 forks source link

IPv6 support #718

Open l9i opened 4 years ago

l9i commented 4 years ago

Describe the problem you have/What new integration you would like ESPHome should be usable (== addressable) on an IPv6-only network.

Please describe your use case for this integration and alternatives you've tried: My HomeAssistant instance used to live on an IPv6-only network until it needed to communicate with an ESPHome node.

Additional context Based on my cursory look, ESP-IDF supports IPv6 with SLAAC.

valpackett commented 4 years ago

Looks like there is already work on mDNS-IPv6 in the arduino core: https://github.com/esp8266/Arduino/pull/7335

Unfortunately enabling IPv6 in lwIP currently breaks ESPAsyncTCP: https://github.com/me-no-dev/ESPAsyncTCP/issues/148

ski7777 commented 3 years ago

Is there any progress on this?

leonelsr commented 3 years ago

Still nothing? Have anyone at least started porting this to IPv6-enabled LWIP?

I am looking for any examples (from forks of this or any other entirely different projects) so I can understand how calls to dual-stack IPAddress structs should look like and how should any interface deal with it, so I/we can start at least some hacky working draft for this...

Does anyone know of any good one?

RHAD1969 commented 3 years ago

What is the status of the IPv6 support? If I implement a new device architecture, I have to be sure that it is future proof.

grischard commented 3 years ago

Enabling IPv6 in lwIP still breaks ESPAsyncTCP, and the issue was unfortunately closed because no one was working on it: me-no-dev/ESPAsyncTCP#148.

That project seems dead - no commits since 2019, and eight pull requests collecting dust.

In any case, it's a problem to be fixed there, and not in esphome. Maybe @me-no-dev can comment? If espressif doesn't intend to invest in ESPAsyncTCP anymore, maybe volunteer maintainers can step in, or the project can be forked?

jack9603301 commented 2 years ago

If possible, I also expect esphome to support IPv6 protocol stack, and I think this is the trend in the future

Ruakij commented 2 years ago

v6 is the future and will also make many things easier e.g. static-ips without dhcp (faster link-local-addresses)

Hedda commented 2 years ago

Matter (formerly Project CHIP) Application Layer support requirements might be very strong argument why IPv6 support is needed.

Created separate feature request discussion for Matter/CHIP Application Layer support in https://github.com/esphome/feature-requests/issues/1430 but looks like IPv6 is required now.

Hedda commented 2 years ago

hmm, do these documents from ESP-IDF Programming guide for ESP32 v4.3.1 make it sound like IPv6 is supported on ESP32?

https://docs.espressif.com/projects/esp-idf/en/v4.3.1/esp32/api-guides/lwip.html?highlight=ipv6

ESP-IDF version of lwIP (esp-lwip) list IPv6 support under FEATURES:

https://github.com/espressif/esp-lwip/blob/2.1.2-esp/README

https://github.com/espressif/esp-lwip

grischard commented 2 years ago

The blocker here is IPv6 support on the esp8266. It would be unfortunate if esphome only supported ipv6 on the esp32.

Hedda commented 2 years ago

The blocker here is IPv6 support on the esp8266. It would be unfortunate if esphome only supported ipv6 on the esp32.

OK then that is understandable. Espressif and the Matter/CHIP only support Matter/CHIP Application Layer on ESP32 anyway.

HeMan commented 2 years ago

I looked a bit into this, and created an updated ESPAsyncTCP that works with IPv6, https://github.com/HeMan/ESPAsyncTCP/tree/ipv6 and I have a local version of https://github.com/HeMan/esphome/tree/ipv6 that could at least start web_server on an ESP8266. It seems that the Arduino for ESP32 doesn't have IPv6 support, but I'll try to get it to work with esp-idf.

HeMan commented 2 years ago

ESPHome 2022.2.0 was released with IPv6 support for esp-idf framework, https://esphome.io/changelog/2022.2.0.html#new-features

grischard commented 2 years ago

Note that the esp-idf framework doesn't support some components (yet), for example the web server or the captive portal.

Nardol commented 2 years ago

@nagyrobi can we really consider this as completed as it is only available with ESP-IDF which still not support all component and is only for ESP32?

nagyrobi commented 2 years ago

AFAIK the long-term goal is to move everyting to ESP-IDF. And indeed you're riht, ESP-IDF platform is still missing Ethernet support in ESPHome, so actually things depend on each other. However, I think the first big step has been done, ice broken - with compromises but yes, can be used.

Nardol commented 2 years ago

And what about ESP8266? I thought ESP-IDF was only for ESP32, which is the case in ESPHome.

About not supported components I was referring for example to captive portal which is still not compatible with ESP-IDF, because of web server which is not yet compatible if I am not wrong. But I suppose in long term it will be compatible...

wtremmel commented 2 years ago

Also I cannot compile esp-idf on Raspberry PI4

HeMan commented 2 years ago

I have a working IPv6 implementation for ESP8266 that needs some work. Some of the components doesn't support IPv6, and I have a created a PR to solve one (https://github.com/OttoWinter/ESPAsyncTCP/pull/4). IPv6 on the Arduino version for ESP32 needs a newer Arduino than what Platform.io had when I last looked into it, but that could have changed now.

MaZe3D commented 1 year ago

Tasmota has gained great success in implementing IPv6 for ESP32 and ESP8266. Details can be found in the related issue https://github.com/arendst/Tasmota/issues/2521 and their release notes https://github.com/arendst/Tasmota/releases/tag/v12.4.0. Maybe their implementation is helpful or even compatible to reuse in esphome.

HeMan commented 1 year ago

Finally got some time to work on IPv6 support and have created two PRs, https://github.com/esphome/esphome/pull/4750 and https://github.com/esphome/esphome/pull/4759. The second one needs https://github.com/OttoWinter/ESPAsyncTCP/pull/4 https://github.com/esphome/ESPAsyncTCP/pull/1 to be merged before it compiles. Next step is to enable it for Ethernet as well. RP2040 is unfortunately a lot harder to get working with IPv6.

HeMan commented 1 year ago

Got IPv6 to work with Ethernet as well, https://github.com/esphome/esphome/pull/4807

Hedda commented 1 year ago

Originally posted by @HeMan in https://github.com/esphome/esphome/issues/4807#issuecomment-1544766968

This just adds dynamic IPv6 via SLAAC or DHCPv6, in par with IPv6 for ESP-IDF (https://github.com/esphome/esphome/pull/2953). Adding static addresses needs a bigger internal change that starts with https://github.com/esphome/esphome/pull/4729.

Off-topic but an indirectly related question; dynamic IPv6 addresses should be compatible with Matter standard/protocol, right?

Question is related to this other ESPHome feature request for Matter standard/protocol support -> https://github.com/esphome/feature-requests/issues/1430

As I understand the core Matter protocol should in theory be able to communicate over any type of IPv6 transport and network.

HeMan commented 1 year ago

Off-topic but an indirectly related question; dynamic IPv6 addresses should be compatible with Matter standard/protocol, right?

Question is related to this other ESPHome feature request for Matter standard/protocol support -> #1430

As I understand the core Matter protocol should in theory be able to communicate over any type of IPv6 transport and network.

I think so. Dynamic addressing, especially on IPv6, is a more convenient way to maintain a network. Static addresses have it uses so I'm still going to implement it, but I think the main part is going to use dynamic addresses.

wtremmel commented 1 year ago

Keep in mind there are two kind of dynamic address assignment in IPv6: SLAAC and DHCPv6. For IoT devices, address assignment via DHCPv6 might not be necessary (Android devices for example also cannot use DHCPv6 to get an IPv6 address).

If you want to read up about IPv6, there is a nice public book here on Github: https://github.com/becarpenter/book6

HeMan commented 11 months ago

I now have basic IPv6 working on all platforms and have started to rewrite the internals to be more address agnostic. It also need to understand that it could have multiple addresses, since IPv6 could have a few and also since it will be dual stack it could have one IPv4 address. DNS-resolving for MQTT for example need to look for both A- and AAAA-records, and happy eyeballs should perhaps be implemented as well.

wtremmel commented 11 months ago

I just enabled IPv6 on one of my sensors - but debug output did not show any IPv6 addresses being assigned. Checking my firewalls NDP table I only see a link-local address for this device. Do I need to enable any additional debug to see IPv6 related messages?

HeMan commented 11 months ago

I just enabled IPv6 on one of my sensors - but debug output did not show any IPv6 addresses being assigned. Checking my firewalls NDP table I only see a link-local address for this device. Do I need to enable any additional debug to see IPv6 related messages?

Could you please open a issue with information about hardware and the important parts of your yaml.

HeMan commented 10 months ago

Yey, PR for enabling IPv6 on ESP8266 and RP2040 (Raspberry Pi Pico) was merged yesterday! 🥳

HeMan commented 5 months ago

I think this could be close after https://github.com/esphome/esphome/pull/5449 is merged. Could you people test it when it gets merged or from my branch now?

kquinsland commented 5 months ago

I think this could be close after esphome/esphome#5449 is merged. Could you people test it when it gets merged or from my branch now?

Thank you for all the work you've done on this! <3.

I was planning on taking some time this weekend to update all my devices now that 24.02 is out but I can try pulling in your branch.

The yaml should look like this:

external_components:
  - source: github://pr#5449
    components: [ wifi_info ]

Or does components need the full suite: ethernet, ethernet_info, mqtt, network, socket, wifi, wifi_info ?

HeMan commented 5 months ago

I think this could be close after esphome/esphome#5449 is merged. Could you people test it when it gets merged or from my branch now?

Thank you for all the work you've done on this! <3.

I was planning on taking some time this weekend to update all my devices now that 24.02 is out but I can try pulling in your branch.

The yaml should look like this:

external_components:
  - source: github://pr#5449
    components: [ wifi_info ]

Or does components need the full suite: ethernet, ethernet_info, mqtt, network, socket, wifi, wifi_info ?

You need to clone my repo and check out the branch. It can unfortunately not be used as an external component.

HeMan commented 5 months ago

It is now merged so you should be able to use the dev-branch.

HeMan commented 4 months ago

It's now released as part of 2024.3, https://esphome.io/changelog/2024.3.0.html#ipv6. There are some more things I'd like to add, like support for IPv6 only networks, but it should be usable in dual stack environments for now. Could you people test?

wtremmel commented 4 months ago

It did not work in one of my IPv6 only-networks. Kept disconnecting (like if it does not have an IPv4 address it did not consider itself connected).

Also (in a dual stack network) it does not add an IPv6 DNS address. (using RA only. No DHCPv6).

HeMan commented 4 months ago

It did not work in one of my IPv6 only-networks. Kept disconnecting (like if it does not have an IPv4 address it did not consider itself connected).

Yeah, that is expected since it still deserves IPv4 to consider started.

Also (in a dual stack network) it does not add an IPv6 DNS address. (using RA only. No DHCPv6).

Did you mean mDNS? Regular DNS could not be updated with SLAAC. And mDNS works best with esp-idf version 5.0.x or above unfortunately.

wtremmel commented 4 months ago

Did you mean mDNS? Regular DNS could not be updated with SLAAC.

Perhaps something worth working on. I really dream about getting rid of IPv4 completely for my internal networks...

HeMan commented 4 months ago

Did you mean mDNS? Regular DNS could not be updated with SLAAC.

Perhaps something worth working on. I really dream about getting rid of IPv4 completely for my internal networks...

mDNS could be worth working on. SLAAC does only send out information regarding the network, it doesn't get anything back, which means that it can't update a DNS. DHCPv6 could do that, but lwip doesn't support that part of DHCPv6.

aaliddell commented 4 months ago

Did you mean mDNS? Regular DNS could not be updated with SLAAC.

Perhaps something worth working on. I really dream about getting rid of IPv4 completely for my internal networks...

mDNS could be worth working on. SLAAC does only send out information regarding the network, it doesn't get anything back, which means that it can't update a DNS. DHCPv6 could do that, but lwip doesn't support that part of DHCPv6.

DNS is optionally present in the RA packets used for SLAAC: https://datatracker.ietf.org/doc/html/rfc8106

So when you receive RA required to do SLAAC, you could take the IPv6 DNS info if it is present without having to use DHCPv6.

Nardol commented 4 months ago

mDNS could be worth working on. SLAAC does only send out information regarding the network, it doesn't get anything back, which means that it can't update a DNS. DHCPv6 could do that, but lwip doesn't support that part of DHCPv6.

DNS is optionally present in the RA packets used for SLAAC: https://datatracker.ietf.org/doc/html/rfc8106

So when you receive RA required to do SLAAC, you could take the IPv6 DNS info if it is present without having to use DHCPv6.

Yes, named RDNSS if I am not confusing with something else. I don't know if lwip supports it.

HeMan commented 4 months ago

RDNSS is to anounce which DNS server to use, not to update the DNS-server. RDNSS is supported by lwip.

HeMan commented 4 months ago

Oh, now I see what you mean! RDNSS do set the DNS server on the ESP, but it's not shown in the log. Just tried to remove my DNS setting in the DHCP server and just propagated it via SLAAC and resolving of addresses worked. Will try to figure out how to display it.

Nardol commented 4 months ago

For MDNS and ESP8266, does esphome/esphome#5359 change how IPv6 is supported?

kquinsland commented 4 months ago

Yeah, that is expected since it still deserves IPv4 to consider started.

Is there a list of $things in ESPHome that still rely on IPv4?

HeMan commented 4 months ago

ESPHome networking components (ethernet and wifi) needs an IPv4 address to assume a connection. I haven't looked at what other components that communicates over IP that still needs IPv4.

Hedda commented 2 months ago

There are some more things I'd like to add, like support for IPv6 only networks

I guess one future scenario for IPv6-only devices is how and when native support for OpenThread (Thread) is added to ESPHome?

"IThread is an Pv6-based networking protocol designed for low-power Internet of Things devices in an IEEE 802.15.4-2006 wireless mesh network, commonly called a Wireless Personal Area Network (WPAN). Thread is independent of other 802.15 mesh networking protocols"

FYI, that includes ESP32-H2 and ESP32-C6 (and newer SoCs), but note there is a separate feature request for OpenThread here:

PS: Off-topic but FYI, there is also an OpenThread proof-of-concept project for ESPHome discussed in community forum here:

https://community.home-assistant.io/t/announcement-esphome-running-on-adafruit-52840-over-thread-mesh-networking-using-zephyrrtos/363712