Skip to content

IPv6 DNS servers are not received correctly #5561

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

Closed
6 tasks done
davefiddes opened this issue Dec 27, 2018 · 4 comments
Closed
6 tasks done

IPv6 DNS servers are not received correctly #5561

davefiddes opened this issue Dec 27, 2018 · 4 comments

Comments

@davefiddes
Copy link
Contributor

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: WeMos D1 R1 clone
  • Core Version: e3bc3c2
  • Development Env: Arduino IDE
  • Operating System: Fedora 29

Settings in IDE

  • Module: WeMos D1 R1
  • Flash Mode: Board default
  • Flash Size: 4MB (No SPIFFS)
  • lwip Variant: v2 IPv6 Lower Memory & v2 IPv6 Higher Bandwidth
  • Reset Method: Board default
  • Flash Frequency: Board default
  • CPU Frequency: 80Mhz
  • Upload Using: SERIAL
  • Upload Speed: 921600

Problem Description

I am testing the IPv6.ino sample on my home network which has both IPv4 DHCP and IPv6 DHCPv6 support. Both DHCP protocols deliver DNS server addresses to clients. The IPv6.ino sample fails to resolve the two domains as the DNS server address used is gibberish. Occasionally DHCPv4 wins the race condition within the stack and the IP address is the network IPv4 DNS server. As my DNS server is dual-stacked it is able to resolve all domains.

MCVE Sketch

ESP8266WiFi | IPv6 example

I have deleted the line below for clarity in the output:

dns_setserver(DNS_MAX_SERVERS - 1, IPAddress(8, 8, 8, 8));

Debug Messages

Broken DNS IPv6 address (it should be 2001:470:XXXX:2b6::3)

------------------------------
SDK:3.0.0-dev(c0f7b44)/Core:2.5.0-beta2-15-ge3bc3c22=20499902/lwIP:IPv6+STABLE-2_1_2_RELEASE/glue:1.0-5-g51b2d6c/BearSSL:2398cc6
dns0: 32.1.4.112 IPv6:No
Try me at these addresses:
(with 'telnet <addr> or 'nc -u <addr> 23')
IF='st' IPv6=0 local=0 hostname='ipv6test' addr= 192.168.1.237 / mask:255.255.255.0 / gw:192.168.1.1
IF='st' IPv6=1 local=1 hostname='ipv6test' addr= fe80::a220:a6ff:feXX:XXXX
IF='st' IPv6=1 local=0 hostname='ipv6test' addr= 2001:470:XXXX:2b6:a220:a6ff:feXX:XXXX
resolving www.google.com: timeout or not found
resolving ipv6.google.com: timeout or not found
------------------------------

Working IPv4 DNS server address:

------------------------------
SDK:3.0.0-dev(c0f7b44)/Core:2.5.0-beta2-15-ge3bc3c22=20499902/lwIP:IPv6+STABLE-2_1_2_RELEASE/glue:1.0-5-g51b2d6c/BearSSL:2398cc6
dns0: 192.168.1.3 IPv6:No
Try me at these addresses:
(with 'telnet <addr> or 'nc -u <addr> 23')
IF='st' IPv6=0 local=0 hostname='ipv6test' addr= 192.168.1.237 / mask:255.255.255.0 / gw:192.168.1.1
IF='st' IPv6=1 local=1 hostname='ipv6test' addr= fe80::a220:a6ff:feXX:XXXX
IF='st' IPv6=1 local=0 hostname='ipv6test' addr= 2001:470:XXXX:2b6:a220:a6ff:feXX:XXXX
resolving www.google.com: 172.217.19.68
resolving ipv6.google.com: 2a00:1450:4013:c01::8a
------------------------------
@davefiddes
Copy link
Contributor Author

I have investigated this problem and created a LwIP patch which fixes it:

https://savannah.nongnu.org/patch/index.php?9737

The problem was due to the IP address structure containing the DNS server address not being marked as an IPv6 address which is why the sample output DNS address of 32.1.4.112 equates to the first 32-bits of my DNS server address: 2001:0470.

Rebuilding lwip2 by running:

cd tools/sdk/lwip2/
make latestmaster
cd builder/lwip2-src/
patch -p1 < ~/dhcpv6-dns-fix.diff 
make install

Results in the following output:

------------------------------
SDK:3.0.0-dev(c0f7b44)/Core:2.5.0-beta2-15-ge3bc3c22=20499902/lwIP:IPv6+STABLE-2_1_2_RELEASE/glue:1.0-5-g51b2d6c/BearSSL:2398cc6
dns0: 2001:470:XXXX:2b6::3 IPv6:Yes
Try me at these addresses:
(with 'telnet <addr> or 'nc -u <addr> 23')
IF='st' IPv6=0 local=0 hostname='ipv6test' addr= 192.168.1.237 / mask:255.255.255.0 / gw:192.168.1.1
IF='st' IPv6=1 local=1 hostname='ipv6test' addr= fe80::a220:a6ff:fe19:f70e
IF='st' IPv6=1 local=0 hostname='ipv6test' addr= 2001:470:XXXX:2b6:a220:a6ff:feXX:XXXX
resolving www.google.com: 64.233.184.106
resolving ipv6.google.com: 2a00:1450:400c:c0c::64
------------------------------

I presume to fix this my change will need reviewed and merged upstream before rebuilding and updating in this project which is why I raised this as an Issue rather than a PR.

@d-a-v
Copy link
Collaborator

d-a-v commented Dec 27, 2018

Ah thanks alot !
I just pushed a local fix in #5560 for this exact matter.
I am collecting patches in lwip2 repository, that is currently being used here.

which is why I raised this as an Issue rather than a PR.

If you want to see your patches applied sooner, please do PRs also in lwip2
You fix is nicer than mine, I will accept your version if you PR there.

@davefiddes
Copy link
Contributor Author

OK. Think I understand the workflow better now. Will look at doing this tomorrow.

@d-a-v
Copy link
Collaborator

d-a-v commented Dec 29, 2018

Fixed in d-a-v/esp82xx-nonos-linklayer#23

@d-a-v d-a-v closed this as completed Dec 29, 2018
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

2 participants