IOS local ip address

Is there a way to get the local IP address of an IOS device.

You mean, the IP on the local network ?

It is probably possible through declares. Here is a link to an Objective-C method :
http://stackoverflow.com/questions/7072989/iphone-ipad-osx-how-to-get-my-ip-address-programmatically

From the start screen start:
settings -> WIFI -> i
(translated from Dutch Ipad)

[quote=164324:@Andre Kuiper]From the start screen start:
settings -> WIFI -> i
(translated from Dutch Ipad)[/quote]

Yes, this is how the user gets that information. But I guess what the OP wants is a way to get that information in code.

Anybody ever come up with the declares for this?

Don’t know about the local LAN IP, but it is easy to know your Internet IP with http://WhatisMyIp.com

Using HTTPSocket, it should be possible too access that site API.

Since I can’t post a SWIFT example… here is a link to one… perhaps someone can translate it

http://stackoverflow.com/questions/30748480/swift-get-devices-ip-address

Thanks for the examples guys. Afraid converting that is a bit above me at this point. Would take volunteers! :slight_smile:

Declares into the BSD socket layer is what the example Dave posted requires
It’s all BSD socket code

Since what the example does is out of my scope. Does this mean it can or cannot be done? Is it something Apple does not allow? I am just wanting to record the IP address of punches made in my ipad timeclock application. A means to ensure it was not outside the entity network.

[quote=286476:@Norman Palardy]Declares into the BSD socket layer is what the example Dave posted requires
It’s all BSD socket code[/quote]

If you are thinking of having the iOS device send its IP address as part of a data packet to insure it came from an “authorized” device… why not have each device (as part of this app) generate a UUID code instead… it is way easier to do, and would be just as unique (maybe more so) than the device IP address (since that could change if the device, being mobile and all, changed its proximity to a particular LAN)

Has nothing to do with authentication. Already doing what you suggested. This is more a check for exactly what I said. To ensure the Ipad is on the entities network.

Just out of curiosity, how are you expecting to tell that? Local up addresses are not guaranteed to be unique from one network to the other and many companies use what comes with their routers… 192.168.1.xxx

the only way I can think is for the iOS device to transmit its local IP address to a computer on the LAN and match the first 3 triplets of the IP… but then if it can transmit to that computer, or recieve from it, then that alone indicates its on the same LAN.

As far as keeping “foreign” devices out, IP won’t work, because if they penetrated the LAN, then they already have a “good” IP address.

So… have the iOS device say “HELLO, I’M LOOKING FOR YOU!”, and the LAN say “YEAH I’m here”, then you know it is in the right place… if they don’t “shake hands”, then move on

Like Greg says, most LANS are eitehr 192.168.1.xxx or 10.10.2.xxx … so all you can do is tell you are on “A” Lan, but without some more info you can’t tell WHICH Lan

Thanks guys for wanting to help. But you’re trying to solve a part of the problem I don’t need to solve. I am just wanting to provide that information to the timekeepers at the business. It is a standard practice of the timekeeping applications I have seen to record the ip address of the device used to punch a timecard on the network. It is up to them to determine if its really their network. I am not going to put any logic to verify it. I just need a means to capture the address device currently has. Btw if the device also has cellular I will be recording the location as well.

[quote=286822:@Dave S]the only way I can think is for the iOS device to transmit its local IP address to a computer on the LAN and match the first 3 triplets of the IP… but then if it can transmit to that computer, or recieve from it, then that alone indicates its on the same LAN.

As far as keeping “foreign” devices out, IP won’t work, because if they penetrated the LAN, then they already have a “good” IP address.

So… have the iOS device say “HELLO, I’M LOOKING FOR YOU!”, and the LAN say “YEAH I’m here”, then you know it is in the right place… if they don’t “shake hands”, then move on

Like Greg says, most LANS are eitehr 192.168.1.xxx or 10.10.2.xxx … so all you can do is tell you are on “A” Lan, but without some more info you can’t tell WHICH Lan[/quote]

you do realize don’t you… .if you have a iOS device… say an Iphone…
and you enter the radius of your timekeepers LAN, and that iOS device connects, it will get an IP address
when it leaves the range of the WiFi, or otherwise disconnects, that IP address is freed up, and could be assigned to another iPhone mere seconds later, not to mention the first iPhone will get a NEW IP address the next time it enters range. The Wifi IP address of the device is dynamic, and is never assured to be the same .
So if you are marking a record as being created by a specific device… that is NOT a good way to do it

  • George walks into the building, his iPhone gets 10.10.2.101, he transacts some data with this app
  • George leaves and goes home, IP address 10.10.2.101 is no longer assigned to his iphone for that network
  • Sally walks in after George has left, her iPhone just happens to also get 10.10.2.101… she transacts with the app
  • the recieving computer doesn’t know (soley from the ip stamp) where the data came from

oh, and should the router be rebooted while people are connect to the LAN, when it restarts, everyone could get a totally different IP addrees than they had a few minutes ago

I do appreciate your input. I understand all the examples you stated. Those examples don’t really match my target market. My market is much more controlling of the addresses they assign and in many cases assign specific addresses to devices. Also these devices may or may not be mobile. They will be Ipad only currently. You’re approaching this problem from the prospective that this is going to be some sort of Key information. It is just additional information that may or may not be used by the entity employing it. They will be in control of the validity of it by how they setup their network. I am just needing to provide them that means if they want it.

[quote=286830:@Dave S]you do realize don’t you… .if you have a iOS device… say an Iphone…
and you enter the radius of your timekeepers LAN, and that iOS device connects, it will get an IP address
when it leaves the range of the WiFi, or otherwise disconnects, that IP address is freed up, and could be assigned to another iPhone mere seconds later, not to mention the first iPhone will get a NEW IP address the next time it enters range. The Wifi IP address of the device is dynamic, and is never assured to be the same .
So if you are marking a record as being created by a specific device… that is NOT a good way to do it

  • George walks into the building, his iPhone gets 10.10.2.101, he transacts some data with this app
  • George leaves and goes home, IP address 10.10.2.101 is no longer assigned to his iphone for that network
  • Sally walks in after George has left, her iPhone just happens to also get 10.10.2.101… she transacts with the app
  • the recieving computer doesn’t know (soley from the ip stamp) where the data came from

oh, and should the router be rebooted while people are connect to the LAN, when it restarts, everyone could get a totally different IP addrees than they had a few minutes ago[/quote]

I won’t attempt to dissuade you … I will be leaving this conversation, and leaving you to your own devices (pun)

How are you sending the data in ?
The server may already know the senders IP address as part of a connection and can act accordingly without the client having to specifically send it along as any “extra data”

The address the server would have would be the WAN side address of the entity as it is a Xojocloud server at the moment. There may be times when the Ipad only has connectivity to the local network. So must operate on its own until the Cloud is available.

[quote=286839:@Norman Palardy]How are you sending the data in ?
The server may already know the senders IP address as part of a connection and can act accordingly without the client having to specifically send it along as any “extra data”[/quote]