Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Libcurl: force ipv4 or ipv6

Tags:

ipv6

libcurl

How do I force libcurl to access a server running in dual stack mode over either ipv4 or ipv6? It shouldn't be hard to do using IPs addresses, but I'm looking for something that works with DNS ...

like image 796
McEnroe Avatar asked Jul 17 '12 19:07

McEnroe


1 Answers

You bet. The config CURLOPT_IPRESOLVE which can be set to CURL_IPRESOLVE_V4 or CURL_IPRESOLVE_V6.

A more robust solution, if you can control DNS in anyway, is to make an A record for the v4 address and a separate AAAA record for the v6 address. This would let you pick the network you want to poll this system by, regardless of DNS resolution. But CURL can do what you want, just fine.

like image 167
Sam Avatar answered Sep 17 '22 17:09

Sam