Detect Local IP Address on IOS


I have been trying to find a way to get the local IP Address on IOS. I have followed this thread @IOS local ip address and connected to a few individuals without a solution.

So I am placing this in IOS queue to see if someone had a solution that would provide identifying the local IP Address.


I’ve already been down this road with Xojo. They are taking Apple’s stance that it is against privacy policies. So currently there is no available way. An app that used the required calls wouldn’t make it through the apple store so would have to be an in house application anyway.

@Steve Koger - the need here is to know what IP Address the device has so appropriate routing can occur. In either case the IP:PORT points to an API interface. It makes no sense to require two application:- one hard coded for internal address and one hard coded for external address to enable use. This really falls apart when one uses Dynamic DNS for routing to specific server.

This is too bizarre. When anyone comes into our server the ASA front end scrubs them and we have that info plus more anyway.

Thanks for your response - appreciate it

Our need was for ensuring timeclock punches were at specific locations. The location services are not always accurate. By being able to provide the devices ip address was from within the customers network. We could provide that amount of assurance they were. Since we are unable to obtain that address programmatically we cannot. FWIW

Callling ipify is helpful for obtaining the public IP you are behind. I thought the OP wanted the local IP. If unable to get that from the socket, you could put a simple console program in the LAN (perhaps using Aloe or your own code) that acts like ipify but returns the IP address of the machine which did the request. That would be the local machine, if connecting over wifi using a LAN access point.

I don’t see why you need the IP when you can do all this with internal and external dns servers.

Just out of curiosity, do you need this data actually on the device? For instance, are you connecting to a server through an api where you might be able to pull the address from?

@Greg O’Lone - I need the application to know its IP so it can make a routing choice. This routing choice is the internal or external IP:PORT for the API. I want to enable this IOS app to be used in house or outside. We are hosting the API In house. Otherwise this will require two apps and thats definitely not preferred.

My suggestion, as it seems you are in control of the internal API, setup an API call that can respond fast. Perhaps call it “ping” or whatever – then in your app try sending a call to the internal server name/ip:port with a pretty low timeout. If you get the expected response, then route API calls to the internal server. If you don’t, route API calls to the external server. At that point you may not really care what your local IP is – only which server you should route the API calls to for the next period of time. But if you do care, just have the internal “ping” command return the IP address of the caller. It should be available to the host server in its socket.

Even if you aren’t in control of the APIs used by the internal server, try sending it a bogus command with bad or unauthorized syntax but use a short timeout and see if it times out or gets back a 4xx or 5xx status code or whatever.

Then your app can also auto-transfer to the external server if the internal server is down for any reason.

The app doesn’t need to know its IP to route to different locations, to make this totally device agnostic use dns, any network admin should know how to implement this:

  1. Set up and internal dns server, alter your internal machines to route via that and get it to forward everything else to your regular domain lookup addresses.
  2. Add your domain to the local server or add a separate sub zone
  3. Add your application address e.g. and point it to an internal address e.g. where your app is hosted
  4. Add your application address to your external dns and point it to your external address e.g.

Use to connect to your application instead of via IP. When you are internal to your network your devices will connect to your local address ( and when you are outside the network they will connect to

Failing that, do as mentioned above and set up a local app on your network that answers a network request of some kind, if it answers then you are internal, if it doesn’t, try the external, or you could have it respond with the request address of the http header.