Skip to content

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

Description

@jsoref

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

Activity

  1. bagder commented on Mar 12, 2024

    @bagder
    Member
    • 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...

  2. jay commented on Mar 12, 2024

    @jay
    Member

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

  3. bagder commented on Mar 12, 2024

    @bagder
    Member

    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.

  4. jay commented on Mar 12, 2024

    @jay
    Member

    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.
  5. bagder commented on Mar 13, 2024

    @bagder
    Member

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

  6. added a commit that references this issue on Mar 15, 2024
    5c8dcbf
  7. added a commit that references this issue on Mar 15, 2024
    79cdae4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions