Skip to content

Ethernet doesn't work with IPV6 #6283

Closed
@copercini

Description

@copercini

Board

ESP32 dev module + LAN8720A

Device Description

ESP32 dev module + LAN8720A

Hardware Configuration

I think the hardware is fine, LAN8720A is working flawless with IPV4

Version

v2.0.2

IDE Name

Arduino IDE

Operating System

Ubuntu 20.04

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

921600

Description

It seems that IPV6 is not working with ethernet interface, I'm trying to add ETH.enableIpV6(); inside ARDUINO_EVENT_ETH_CONNECTED event, but it seems to produce no results, and ARDUINO_EVENT_ETH_GOT_IP6 is never called (check attached code). It's working fine with IPV4

I also checked with Wi-FI STA interface and IPV6 works as expected

Sketch

#include <ETH.h>

static bool eth_connected = false;

void WiFiEvent(WiFiEvent_t event)
{
  Serial.printf("Event: %d\n", event);
  switch (event) {
    case ARDUINO_EVENT_ETH_START:
      Serial.println("ETH Started");
      //set eth hostname here
      ETH.setHostname("esp32-ethernet");
      break;
    case ARDUINO_EVENT_ETH_CONNECTED:
      Serial.println("ETH Connected");

      ////I'm trying to enable IPV6 here
      delay(10);
      ETH.enableIpV6();
      delay(10);
      /////

      break;
    case ARDUINO_EVENT_ETH_GOT_IP:
      Serial.print("ETH MAC: ");
      Serial.print(ETH.macAddress());
      Serial.print(", IPv4: ");
      Serial.print(ETH.localIP());
      if (ETH.fullDuplex()) {
        Serial.print(", FULL_DUPLEX");
      }
      Serial.print(", ");
      Serial.print(ETH.linkSpeed());
      Serial.println("Mbps");
      eth_connected = true;
      break;
    case ARDUINO_EVENT_ETH_DISCONNECTED:
      Serial.println("ETH Disconnected");
      eth_connected = false;
      break;
    case ARDUINO_EVENT_ETH_STOP:
      Serial.println("ETH Stopped");
      eth_connected = false;
      break;

    ////Expecting this IPV6 event, but it never happens
    case ARDUINO_EVENT_ETH_GOT_IP6:
      Serial.println("Ethernet IPv6 is preferred");
      break;
    ////



    default:
      break;
  }
}

void testClient(const char * host, uint16_t port)
{
  Serial.print("\nconnecting to ");
  Serial.println(host);

  WiFiClient client;
  if (!client.connect(host, port)) {
    Serial.println("connection failed");
    return;
  }
  client.printf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", host);
  while (client.connected() && !client.available());
  while (client.available()) {
    Serial.write(client.read());
  }

  Serial.println("closing connection\n");
  client.stop();
}

void setup()
{
  Serial.begin(115200);
  WiFi.onEvent(WiFiEvent);
  ETH.begin(1, 32, 2, 4, ETH_PHY_LAN8720); //ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE
}


void loop()
{
  if (eth_connected) {
    testClient("google.com", 80);
  }
  delay(10000);
}

Debug Message

Event: 18
ETH Started
Event: 20
ETH Connected
Event: 22
ETH MAC: 24:0A:C4:E3:26:4B, IPv4: 192.168.31.52, FULL_DUPLEX, 100Mbps

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions