-1

On my phone, using LTE (not wifi), if I go to whatismyipaddress.com, it reports the IP address as 166.216.xxx.xxx. But if I go to whatismyip.com, it is reported as 107.77.xxxx.xxx. Why is that?

When I connect to my server with my phone (again LTE, not wifi), the server-side ASP.Net code attempts to retrieve the IP address via Request.UserHostAddress, and it is always 166.216.xxx.xxx. But how can I retrieve the 107.77.xxxx.xxx address instead? I've tried using Request.ServerVariables["HTTP_CLIENT_IP"] and Request.ServerVariables["HTTP_X_FORWARDED_FOR"] to no avail (both return null), and Request.ServerVariables["REMOTE_ADDR"] returns the same 166.216.xxx.xxx value as Request.UserHostAddress.

I've tried to limit the scope of my problem to the questions above, so if you can answer those sufficiently, I should (hopefully) be able to solve my issue. But in case you're wondering why this is a problem for me, read on.

I'm developing a phonegap application and on my production server (hosted in Azure) Request.UserHostAddress returns the 166.216.xxx.xxx IP address when I connect to it via the mobile browser (Safari) BUT returns the 107.77.xxxx.xxx IP address when I connect to it via my phonegap app.

I'm attempting to do so some very short-term, time-sensitive, identification of the connecting user's device when they access my server via the mobile browser (Safari), and then subsequently access it via the installed phonegap app, and the IP address figures into the algorithm, but because it's reported differently from the mobile browser vs the app it doesn't work properly.

At first I thought it was something to do with the how the phonegap app's network connectivity works (and it still might be) but because I'm able to get two different IP addresses reported from whatismyipaddress.com and whatismyip.com when accessing those sites via the mobile browser (Safari), I figure it has more to do with the technique used to retrieve the client IP address.

Any help would be greatly appreciated, Thanks.

Redwing19
  • 75
  • 7

1 Answers1

0

Your carrier is using CGN. That means your iPhone does not have a public IP address. The carrier whose tower you are connected to has public IP addresses, and that is what gets reported to you by a public web site.

The public IP address which gets reported will vary for different reasons:

  • If you are connected to a different tower than when you checked before, the carrier on the tower could actually be a different carrier (different than the carrier to which you are contracted).
  • Even a single carrier can have different NAT points where your traffic may be routed, depending on the tower to which you are connected, or how your traffic may be routed to different other ISPs on the way to the different web sites.
Ron Maupin
  • 6,180
  • 4
  • 29
  • 36
  • But why would it be reported differently when connecting to my server via Safari vs the phonegap app? It's the same device connecting to the same server from the same physical location, but the phonegap app gets reported as 107.77.xxx.xxx while Safari is reported as 166.216.xxx.xxx. – Redwing19 Oct 14 '16 at 14:28