Layer: Foundation ยท Build flags: PROTOCORE_ENABLE_IPV6
The server is already dual-stack: the TCP and UDP listeners bind IPADDR_TYPE_ANY, so the moment the interface has an IPv6 address it answers over v6 as well as v4. All you add is turning IPv6 on for the network interface:
PROTOCORE_ENABLE_IPV6 gates the bring-up. Physical.ip6->init() enables IPv6 on the netif (SLAAC gives a fe80:: link-local address, plus a global one if a router advertises a prefix). Physical.ip6->global_addr() reads the acquired global address straight from lwIP into a protocore_ip.
network_drivers/network/ip.h is one family-tagged type for both v4 and v6, with:
It is pure and host-tested (pio test -e native_ip), so the address handling is verified off-device; the netif bring-up is ESP32-only.
Flash, open Serial @ 115200 for the addresses, then (note the brackets and curl -g):
The flag must reach the whole library build:
Requires an lwIP built with LWIP_IPV6=1 (the stock Arduino-ESP32 core ships it). In the Arduino IDE the build_opt.h beside this sketch sets the flag for you.