问题
In IPV6 how to build CURL POST http request with the IPV6 address and port number.Any kind of thread will be appreciated.
Tried to build the request as below
>curl --interface 'http://[2001:0:db8:1111:0:0:0:11]:8091/?'
But above gave error as "curl: NO URL specified"
>curl -X POST -d curl -X POST `http://[2001:0:db8:1111:0:0:0:11]:8091/?`
Then tried the above that gave error as
>bash: http://[2001:0:db8:1111:0:0:0:11]:8091/?: No such file or directory
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
Is there any alternate method, other than using URL
回答1:
curl -g -d post 'http://[2001:0:db8:1111:0:0:0:11]:8091/'
The -g option was necessary "back in the old days" when you used IPv6 addresses. It stops curl from treating the [] symbols in the URL as globbing instructions. (since curl 7.37.0 (May 2014), curl no longer mistakes numerical IPv6 addresses for globbing, making the use of -g in this case no longer necessary)
The -d is of course for posting. You can slap on a -v too to get to see details from the operation.
回答2:
curl -4
for an IPv4 request and
curl -6
for an IPv6 request are the arguments, that you can use.
For your examle, this should work:
curl -6 -d post 'http://2001:0:db8:1111:0:0:0:11:8091/'
来源:https://stackoverflow.com/questions/24302447/ipv6-curl-post-request