1

I have checked almost all Stackoverflow answers and follow them all. But I every time get the Default Gateway IP instead of External IP

I don't want to use ThirdParty APIs who list back IP Address in Response. I want to use only Swift or Objective-C code to retrieve External IP.

Default Gateway IP => 100.45.150.231
External IP        => 106.72.187.241

Any help would be appreciated.

krunal
  • 452
  • 3
  • 11
  • 1
    If your device is behind a NAT gateway, you need to ask a host on the Internet what IP address it sees for you. The device itself doesn't know as the NAT is transparent. – Paulw11 Nov 26 '18 at 07:04
  • I need External IP using iOS System Native code only. I don't want to call ThirdParty Web API. And this another question is only showing up the results of ThirdParty Web API. So please check and remove from Duplicate. – krunal Nov 26 '18 at 08:29
  • 2
    It isn’t possible to do that. The iOS device doesn’t know anything about the external IP address. Only devices outside the NAT gateway can see the external address – Paulw11 Nov 26 '18 at 08:31
  • Oh Ok, I got your point. But I have a doubt regarding below point. Verizone, AT&T, Sprint, T-Mobile assign private IP Addresses to each devices. So how do they manage to do this? – krunal Nov 26 '18 at 08:34
  • 2
    Because they use Network Address Translation (NAT) to rewrite the packet headers as they traverse their network boundary – Paulw11 Nov 26 '18 at 08:43
  • Oh ok. Thank you. :) – krunal Nov 26 '18 at 08:48

0 Answers0