netbirdio / netbird

Connect your devices into a single secure private WireGuard®-based mesh network with SSO/MFA and simple access controls.
https://netbird.io
BSD 3-Clause "New" or "Revised" License
9.83k stars 425 forks source link

Musl's `getaddrinfo` cannot resolve peer names from Netbird's client DNS #2098

Open glaeqen opened 1 month ago

glaeqen commented 1 month ago

Describe the problem

Programs linked against muslc cannot resolve the peer name against a DNS provided by Netbird client . getaddrinfo with default addrinfo returns EAI_NONAME.

Musl's getaddrinfo with default settings (specifically addrinfo.af_family == AF_UNSPEC) asks for both A and AAAA entry. If any response contains a flag "No such name", error EAI_NONAME is returned. This behaviour is different in glibc. Relevant mailing list: https://www.openwall.com/lists/musl/2021/07/19/8

To Reproduce

Steps to reproduce the behavior:

  1. Connect to a netbird network.
  2. $ docker run --network host -it alpine
  3. In a container: $ ping <valid-peer-domain-name>
  4. Failure occurs

You can also see that choosing to resolve only IPv4 works $ ping -4 <valid-peer-name

Expected behavior

Proper peer name resolution. Not sure what Netbird's DNS should do but DNSes for example for github.com seem to respond with an empty response but a flag is "No error" instead of "No such name"? Not sure.

Thanks a lot.