Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiFiClient cannot connect to IPv6 link local address #6626

Open
6 tasks done
Jamesits opened this issue Oct 10, 2019 · 5 comments
Open
6 tasks done

WiFiClient cannot connect to IPv6 link local address #6626

Jamesits opened this issue Oct 10, 2019 · 5 comments

Comments

@Jamesits
Copy link

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: ESP8266MOD
  • Core Version: 2.5.2
  • Development Env: Arduino IDE
  • Operating System: Windows

Settings in IDE

  • Module: Wemos D1 R2 & mini
  • Flash Size: 4MB
  • lwip Variant: v2 IPv6 Higher Bandwidth
  • Reset Method: ck
  • CPU Frequency: 80Mhz
  • Upload Using: SERIAL
  • Upload Speed: 921600

Problem Description

As per #5136, IPv6 is supported on the recent versions of ESP8266. However, I observed that WiFiClient.connect() is not able to connect to an IPv6 link-local IP address (fe80::/10) on the same network with the ESP8266.

MCVE Sketch

#include <ESP8266WiFi.h>

#define STA_SSID "your-ssid"
#define STA_PSWD "your-wifi-password"
#define SERVER_IP "fe80::aaaa:bbff:fecc:dddd"

IPAddress server;
WiFiClient client;

void setup() {
  Serial.begin(115200);

  WiFi.mode(WIFI_STA);
  WiFi.setAutoConnect(true);
  WiFi.setAutoReconnect(true);
  WiFi.begin(STA_SSID, STA_PSWD);
}

void loop() {
    Serial.println("\nStarting connection...");
    // if you get a connection, report back via serial:
    server.fromString(SERVER_IP);
    if (client.connect(server, 8000)) {
      Serial.println("connected");
      // Make a HTTP request:
      client.println("GET / HTTP/1.0");
      client.println();
    } else {
      Serial.println("Failed to connect");
    }
    delay(500);
}

Debug Messages

Sketch output:

Starting connection...
Failed to connect

I've done a packet capture on the server and can see NO packets from ESP8266.

@theGeekyLad
Copy link

Is there any update on this?

@d-a-v
Copy link
Collaborator

d-a-v commented Jan 4, 2022

I am still not an IPv6 specialist.

My linux laptop cannot reach my server through fe80: and I need to add the interface name,
like: $ ping fe80:...:852c%wlp2s0.
However $ ping fd6f:...:852c works.

Can you give it a try ?

@Jamesits
Copy link
Author

Jamesits commented Jan 5, 2022

@d-a-v Normally you'd need to bind to an interface when using fe80 link-local IPs since they are bound to an interface. There is no way to do this on the ESP8266 SDK...

@d-a-v
Copy link
Collaborator

d-a-v commented Jan 5, 2022

lwIP has it and we use it:

#if LWIP_IPV6
// Set zone so that link local addresses use the default interface
if (IP_IS_V6(&_pcb->remote_ip) && ip6_addr_lacks_zone(ip_2_ip6(&_pcb->remote_ip), IP6_UNKNOWN)) {
ip6_addr_assign_zone(ip_2_ip6(&_pcb->remote_ip), IP6_UNKNOWN, netif_default);
}
#endif

#if LWIP_IPV6
// Set zone so that link local addresses use the default interface
if (IP_IS_V6(addr) && ip6_addr_lacks_zone(ip_2_ip6(addr), IP6_UNKNOWN)) {
ip6_addr_assign_zone(ip_2_ip6(addr), IP6_UNKNOWN, netif_default);
}
#endif

netif_default should be set to the STA interface (<= this is next version and this is current version).

@d-a-v
Copy link
Collaborator

d-a-v commented Jan 5, 2022

I was asking to try because fd6f: is not public and is a reserved address dedicated to local area, as fe80: is reserved for the link only. I don't remember and I have no ipv6 environment right now to check if the ipv6 implementation of lwIP binds to this domain too.
Please correct me if I'm mistaken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants