通过命令行参数 --ipv4
或 -4
强制使用 ipv4 协议:
curl --ipv4 https://example.org/
通过命令行参数 --ipv6
或 -6
强制使用 ipv6 协议:
curl --ipv6 https://example.org/
加上参数 -v
可以看到连接的过程:
curl -v http://example.org/ ~ * Trying 192.168.199.217... * TCP_NODELAY set * Connection failed * connect to 192.168.199.217 port 80 failed: Connection refused * Trying 2001::1... * TCP_NODELAY set * Connected to example.org (2001::1) port 80 (#0) > GET / HTTP/1.1 > Host: example.org > User-Agent: curl/7.64.1 > Accept: */* > html body