Use IPv4 address to send curl commands

Operating system: Ubuntu
OS version: 18.04

I’m using an API that I call from PHP using Curl. They have an IP whitelisting option and they don’t support IPv6 addresses. I have my IPv4 address added to the whitelist there but my requests are getting blocked. They tell me that they’re receiving requests from my IPv6 address.

This has probably happened recently (with an update perhaps) because I’ve been using this API for a long time and recently it stopped working.

Is there something I can do to send these requests from IPv4 address? It would be preferable if this setting is server specific and doesn’t affect other virtualmin servers/domains.

Who is “they”?

I have no idea. This isn’t a Virtualmin question.

My assumption would be that if the name of the server resolves to an IPv4 address(es), and you have an IPv4 route to that server, that the request would go out via IPv4.

Check your routing table and do a traceroute to the server to see the hops.

“they” is the company providing the API. The API is used to send SMS.

The traceroutes are resolving to IPv4 address. My server is from Linode. Here’s the domain in question if it helps you: spinecomfort.in

Could be that their server/network uses the IPv6 route and hence see my IPv6 address?

Not knowing how your curl command looks, can’t you just add a ‘-4’?

1 Like

Thanks. I didn’t knew about this feature. Solved the problem using this SO answer

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.