← index #3683Issue #12600
Related · high · value 1.481
QUERY · ISSUE

IPv6 Support in micropython for ESP32 (or anything for that matter)

openby owendelongopened 2018-03-26updated 2026-01-25
port-esp32

It looks like LWIP in the ESP-IDF being used for micropython has IPv6 support.

Is there an effort to take advantage of the yet? I found some documentation which stated that IPv6 support was "port" dependent, but I have yet to find any port of micropython with IPv6 support enabled.

It looks like the current build has IPv6 capabilities in the usocket module, but it looks like there are no IPv6 capabilities in the network or WLAN class implementations which means that the interface can't get an IPv6 address, etc.

I'm willing to put some effort into trying to do the needful, but the existing API seems to be so thoroughly incapable of understanding that there could possibly be any protocol other than IPv4 that I'm unsure how to go about providing a mergeable codebase that wouldn't break people's existing code.

Further, I'd like to know if there are any standard APIs for IPv6 interface configuration that I should be following as the existing interface configuration capabilities in the ESP32 port are quite thoroughly incapable of such.

Any pointers (or ideally a solution already developed) greatly appreciated.

CANDIDATE · ISSUE

IPv6 APIs

closedby darconeousopened 2023-10-05updated 2024-03-19
enhancement

There are already various bugs tracking adding IPv6 to the various ports:

  • ESP32: #3683, #11111
  • RP2: #9108
  • Other: #7563
  • Maybe more...?

But, even with these changes, there are some critical missing parts: the APIs. For example, <netif>.ifconfig() returns a tuple of the IPv4 address configuration. However, there is no API to get the IPv6 addresses of the device, and it looks like such a thing isn't even defined yet.

So I wanted to open this issue to discuss potential API additions to help make IPv6 a first-class citizen in micropython.

Specifically, we need the ability to:

  1. List the current IPv6 addresses assigned to an interface, along with the status of each address
  2. Statically configure IPv6 addresses, along with adding the associated on-link routes
  3. Turn on/off SLAAC (if support is compiled in)
  4. Turn on/off DHCPv6 (if support is compiled in)
  5. Set a preference for IPv6 vs IPv4 when performing name lookups that have both A and AAAA records.

We currently don't have any way to do any of this from Micropython, so I think we should at least start to define what this should look like.

For compatibility reasons, I think we should avoid extending the ifconfig() method. Lots of code seems pretty dependent on how this method works. I was thinking something like this as a starting point:

  • <netif>.MAX_IPV6_ADDRS - constant describing the maximum number of IPv6 addresses that can be assigned to this interface. (Compile-time default seems to be 3)
  • <netif>.v6_addrs() - Returns a list of tuples, one tuple per address. Each tuple would have the following fields:
    1. IPv6 Address (as a string?)
    2. Flags (Temporary, Deprecated, SLAAC, DHCPv6, Static, on-link, etc)
    3. remaining preferred lifetime (or None)
    4. remaining valid lifetime (or None)
  • <netif>.v6_del_addr(<addr>) - Removes the given IPv6 address.
  • <netif>.v6_add_addr(<addr>, <prefix-len>) - Adds the given IPv6 address, optionally adding a route for other on-link devices with the same prefix.
  • <netif>.config('host-lookup-pref', <'v6'|'v4'>) - Configures the host lookup preference when there are both A and AAAA records.
  • <netif>.config('slaac_en', <True|False>) - Turns on or off SLAAC.
  • <netif>.config('dhcpv6_en', <True|False>) - Turns on or off DHCPv6.

I'm sure this could be improved upon, but wanted to go ahead and put this out there as a starting point.

Thoughts?

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied