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

curl --ipv6 on macOS will connect to an ipv4 address #13112

Closed
jsoref opened this issue Mar 12, 2024 · 5 comments
Closed

curl --ipv6 on macOS will connect to an ipv4 address #13112

jsoref opened this issue Mar 12, 2024 · 5 comments
Labels
appleOS specific to an Apple operating system connecting & proxies

Comments

@jsoref
Copy link
Contributor

jsoref commented Mar 12, 2024

I did this

curl --no-progress-meter -6Iv ipv4.sidn.nl 2>&1 |grep ::
*   Trying [::ffff:212.114.120.63]:80...
* Connected to ipv4.sidn.nl (::ffff:212.114.120.63) port 80

I expected the following

When I try to connect via ipv4 to an ipv6 only host, I get an error:

curl --no-progress-meter -4Iv ipv6.sidn.nl 2>&1
* Could not resolve host: ipv6.sidn.nl
* Closing connection
curl: (6) Could not resolve host: ipv6.sidn.nl

I'd expect to get an error when trying to connect via --ipv6 to an ipv4 only host.

(I'm trying to use --ipv6 to validate a remote server's support for ipv6, not my local kernel's ability to lie and do evil dual stack fallback stuff.)

curl/libcurl version

curl 8.4.0 (x86_64-apple-darwin23.0) libcurl/8.4.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.55.1
Release-Date: 2023-10-11
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL threadsafe UnixSockets

operating system

Darwin jsoref-mbp.local 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64

@bagder bagder added connecting & proxies appleOS specific to an Apple operating system labels Mar 12, 2024
@bagder
Copy link
Member

bagder commented Mar 12, 2024

  • Trying [::ffff:212.114.120.63]:80...
  • Connected to ipv4.sidn.nl (::ffff:212.114.120.63) port 80

This is an IPv6 address, a so called IPv4-mapped address.

curl asks to resolve the name as IPv6-only and it gets an IPv6 address from the OS that it uses, and it works. I don't see what else curl can do here...

@jay
Copy link
Member

jay commented Mar 12, 2024

is it though? it's IPv4 mapped. it's still IPv4 it's just making it look like IPv6 for compatibility

@bagder
Copy link
Member

bagder commented Mar 12, 2024

It is an IPv4 address mapped into an IPv6 address. IPv4 is 32 bit only, it couldn't have room for the extra 16 bits of ffff in the beginning. So it is clearly partly IPv6.

@jay
Copy link
Member

jay commented Mar 12, 2024

how about this

diff --git a/docs/cmdline-opts/ipv6.md b/docs/cmdline-opts/ipv6.md
index fbacbec..d4e9de1 100644
--- a/docs/cmdline-opts/ipv6.md
+++ b/docs/cmdline-opts/ipv6.md
@@ -22,3 +22,6 @@ Example:
 
 This option tells curl to use IPv6 addresses only when resolving hostnames,
 and not for example try IPv4.
+
+Note your resolver may respond to an IPv6-only resolve request by returning
+IPv6 addresses that contain "mapped" IPv4 addresses for compatibility purposes.

@bagder
Copy link
Member

bagder commented Mar 13, 2024

Yes, sensible. Maybe even highlight that macOS is known to do this.

bagder added a commit that referenced this issue Mar 15, 2024
Reported-by: Josh Soref
Assisted-by: Jay Satiro
Fixes #13112
@bagder bagder closed this as completed in 79cdae4 Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
appleOS specific to an Apple operating system connecting & proxies
Development

Successfully merging a pull request may close this issue.

3 participants