How to curl using IPv6 address?
Solution 1
after some testing, I find the following command works:
$ curl -g -6 'http://[fe80::3ad1:35ff:fe08:cd%eth0]:80/'
interface 'eth0' is the interface with ipv6 enabled, so you may need to replace it with something else.
and just in case, the telnet command to test ipv6:
$ telnet -6 fe80::3ad1:35ff:fe08:cd%eth0 80
Solution 2
From man curl
--interface specify interface e.g. eth0:1
curl --interface eth0 -g -6 'http://[2606:2800:220:1:248:1893:25c8:1946]:80/index.html' -H 'Host: www.example.com'
It feels like you are expecting curl to manipulate your machine's interfaces to add-and-then-use a specific /128 ? If you want that you will probably have to write your own shell wrapper.
Related videos on Youtube
Andrew
Updated on July 09, 2022Comments
-
Andrew almost 2 years
I have a VPS with a /64 IPv6 assigned to it. When I try to curl using one of the IPs in the block, this is the error I get:
curl --interface '2a02:c207:2010:1077::2' http://example.com curl: (45) bind failed with errno 99: Cannot assign requested address
What exactly do I need to do to fix this? Shouldn't I be able to use any IP on the machine when logged in as root?
Basically I just need the ability to curl using any IPv6 assigned to the VPS.
-
ewindes almost 7 yearsWhat do you mean by "with a /64 IPv6 assigned to it."? Is there a network interface configured to use the IPv6 address in question? You're telling curl to use the interface with that address.
-
-
Roman Orac about 6 years@Kenster is asking how to use a specific ipv6 address with curl
-
Alexx Roche about 6 yearsYes. and I explained that they are looking at the wrong ISO OSI layer. curl just lets you specify which interface. If you want to set the IPv6 source address them you need something that is not curl to set that.
-
Alexx Roche over 3 yearsDoes your Apache have IPv6 enabled? What do the Apache logs say?