Libcurl: force ipv4 or ipv6

ipv6, libcurl

Solution

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.

Problem

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 ...

Original source