-1

I'm using REMOTE_ADDR to fetch ip for use, it's returning to me my company IP: 192.168.30.124 which doesn't match in my maxmind location database and sites like ipstack

However when I go to sites like, they're able to retrieve my public IP which is 103.52.62.220 and the correct country. What am I missing.

2
  • @PaulCrovella I came up some theories how to fix, tried it all and failed that's why I needed to post again. Commented Jul 12, 2018 at 6:16
  • I see thanks for the heads up man. Commented Jul 12, 2018 at 6:37

2 Answers 2

1

A simple solution presented here by phihag is to do the following:

$externalContent = file_get_contents('http://checkip.dyndns.com/'); preg_match('/Current IP Address: \[?([:.0-9a-fA-F]+)\]?/', $externalContent, $m); $externalIp = $m[1]; 

Simply put, you need to get your public IP from a server that would have to route back through that IP address (a server external to your network).

There is more information about this in the link I provided.

Sign up to request clarification or add additional context in comments.

1 Comment

I tried the same thing using api.ipify.org however it threw me to AUS with IP 103.67.235.63 instead of PH ip: 103.52.62.220, Since I'm under a vpn with same possible same network as the servers I might try looking into what Kapsonfire did below.
0

if the server is in the same network, then you'll get only the local ip, because, theres no reason to leave the intranet just to come back. the router routes it directly to the server with the local ip.

this is tcp related

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.