Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to curl using IPv6 address?

Tags:

linux

shell

curl

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.

like image 986
Andrew Avatar asked Jan 25 '17 04:01

Andrew


People also ask

Does Curl work with IPv6?

0 in December 2013. curl has had IPv6 support since January 2001.

How do I use SSH with IPv6?

The basic restrictions for SSH over an IPv4 transport apply to SSH over an IPv6 transport. The use of locally stored usernames and passwords is the only user authentication mechanism supported by SSH over an IPv6 transport. TACACS+ and RADIUS user authentication mechanisms are not supported over an IPv6 transport.

How do I Ping An IPv6 address?

Activity 8 - Ping an Internet Host by IPv6 Address To test IPv6 Internet connectivity: Type ping 2001:4860:4860::8888 and press Enter. Observe the results. If you see replies indicating success, you have IPv6 Internet connectivity.


2 Answers

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

like image 104
Vincent Avatar answered Sep 17 '22 09:09

Vincent


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.

like image 27
Alexx Roche Avatar answered Sep 20 '22 09:09

Alexx Roche