-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Closed
Description
I did this
SOCKS5 Proxy IPv6 Compatibility Issue
Issue Summary
When using the curl
command with a SOCKS5 proxy on an IPv6 device, users experience an issue when trying to access services like https://api.ipify.io
. Specifically, the following sequence of events occurs:
- The device queries the DNS to obtain the IPv6 address of
api.ipify.io
(note: the query bypasses the proxy DNS). - If the SOCKS5 proxy supports only IPv4, it responds with an error as defined by RFC 1928, Section 6:
X'08' Address type not supported.
- Upon receiving this response, the
curl
command should ideally attempt to retry the connection using IPv4. However, instead of this fallback behavior,curl
exits with an error code, without attempting the IPv4 connection.
This leads to a situation where users must either:
- Manually specify the
-4
flag to force IPv4 usage. - Or, configure the proxy to provide DNS resolution.
Expected Behavior
The expected behavior is that when an IPv6 address is requested and the SOCKS5 proxy cannot handle it, curl
should automatically attempt to resolve and connect using IPv4 instead. This fallback mechanism should be implemented either within the proxy server or within the client behavior.
Steps to Reproduce
- Use the following
curl
command with a SOCKS5 proxy:curl -x socks5://username:password000@ip:port https://api.ipify.io
- On an IPv6-only device, the proxy responds with an error indicating that the address type is not supported.
- Instead of retrying with IPv4, the command exits with an error code.
Workaround
To circumvent this issue, users must:
- Specify the
-4
flag in thecurl
command to force IPv4 resolution, or - Ensure that the proxy DNS is configured to handle the resolution.
Proposed Solution
It is recommended to implement automatic fallback behavior for SOCKS5 proxies when dealing with mixed IPv4 and IPv6 requests. Specifically:
- The proxy should detect an unsupported address type and automatically retry the request using IPv4.
- Alternatively, this functionality could be integrated into the
curl
client to trigger the fallback mechanism.
References
- RFC 1928 - SOCKS Protocol Version 5: https://tools.ietf.org/html/rfc1928
curl
documentation: https://curl.se/docs/
I expected the following
No response
curl/libcurl version
all version.
operating system
all os.