0

I have a shared hosting with a dedicated ip, when I send a request with curl (php), the receiver sees the server IP, instead of the ip the domain resolves to (the dedicated one).

$ch = curl_init("https://www.showmyip.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
print curl_exec($ch);
curl_close($ch);

My hosting provider says I need to send from the domain to use the dedicated IP, for me it's not possible as the request is necessarily sent by the server. Am I wrong ?

EDIT: My problem is that the shared IP (the server one) is blacklisted by mailjet because of other users, and my request are blocked because my curl requests use the banned IP. It's why I bought a dedicated IP for the domain but it is not used by php. So I need the curl option (if exists) that will "force" curl to use the dedicated IP.

Entretoize
  • 2,124
  • 3
  • 23
  • 44
  • 2
    What's a "domain IP" exactly? – deceze Nov 30 '22 at 07:35
  • Sorry for the shortcut, I mean the IP that the domain resolves to. – Entretoize Nov 30 '22 at 07:42
  • `the receiver sees the server IP.`...it's unclear why this is a problem. What exactly were you expecting / wanting, and why? Are you saying you host a domain name on this server and its DNS maps to a different IP? Its entirely possible for a machine to have multiple IPs. When you send outbound from it, if it's possible to reach the destination from either network (each represented by a different connection with a different IP) the O/S probably has one connection selected as a default which it uses. – ADyson Nov 30 '22 at 07:42
  • 1
    Or there could be other, more complicated reasons for what you're seeing, involving wider configuration of the network to which the machine belongs. This isn't particularly a programming problem – ADyson Nov 30 '22 at 07:45
  • I just found the solution and yes this is a programming one, please unclose the question for me to post the anwser. – Entretoize Nov 30 '22 at 07:49
  • 1
    Is it https://stackoverflow.com/questions/43771420/php-curl-special-network-interface? – deceze Nov 30 '22 at 07:50
  • `It's why I bought a dedicated IP for the domain` that’s an odd solution - instead of using a proxy. – AD7six Nov 30 '22 at 08:09
  • @AD7six sorry but using a proxy IS an odd solution for me, that's the first thing I did... – Entretoize Nov 30 '22 at 08:21
  • Can you vote to reopen ? This is a programming question, I added all details to make it understandable, and this is not a dupplicate, the answer is the same but the man who asked that already knew about "interface" and someone asking itself the question I asked won't find the other question. – Entretoize Dec 01 '22 at 08:29
  • This question now is a signpost to the other question, so future visitors *will* find it. – deceze Dec 01 '22 at 08:34

0 Answers0