To use cURL with SOCKS and resolve DNS remotely, you can combine the -x or --proxy flag with the --socks5-hostname flag. Here's an example:

curl -x socks5h://proxy_host:proxy_port http://example.com

Replace proxy_host and proxy_port with the actual SOCKS proxy address and port you want to use. The socks5h:// prefix tells cURL to use SOCKS5 with remote DNS resolution.

You can also specify the proxy username and password if required:

curl -x socks5h://username:password@proxy_host:proxy_port http://example.com

Again, replace username and password with the credentials for your SOCKS proxy.

Using socks5h:// instead of socks5:// ensures that cURL resolves the hostname remotely through the SOCKS proxy, rather than resolving it locally. This allows you to bypass local DNS settings and resolve the hostname using the proxy's DNS.

最后修改:2023 年 11 月 06 日
如果觉得我的文章对你有用,请随意赞赏