1

I want to detect if my iPhone connects / is connected to my LAN, so I can turn on the lights. This is pretty close to this question https://serverfault.com/questions/91369/how-to-detect-an-iphone-connecting-a-network

I want to detect if my iPhone (with or without a known IP / MAC) is active on the LAN by polling, log scanning, event trigging or something else.

This will be done from the router, which is running Ubuntu, dhcpd and ufw.

One option would be to make the dhcpd run a script on commit, but the iPhone rarely changes IP, so I guess that wouldn't work.

I've tried nmap -v -sP 10.0.0.73 but it only works sometimes. When it does, it outputs this:

Starting Nmap 6.47 ( http://nmap.org ) at 2015-02-12 22:54 CET
Initiating Ping Scan at 22:54
Scanning 10.0.0.73 [2 ports]
Completed Ping Scan at 22:54, 1.61s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 22:54
Completed Parallel DNS resolution of 1 host. at 22:54, 0.00s elapsed
Nmap scan report for 10.0.0.73
Host is up (0.10s latency).
Read data files from: /usr/local/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 1.62 seconds

I've tried some other options, including ping and arp, non of which I've got to work reliably (probably doing something wrong).

Help is greatly appreciated!

  • Probably it's wifi power save policy of IOS. Just after a while suspends traffic for everything using wifi connectivity but not sure it's valid for 3G/4G. I think you don't consider to use jailbreak for changing that policy. i didn't try it with jailbreak (not sure if it's possible) – risyasin Feb 12 '15 at 22:44
  • Correct, I don't want to jailbreak for this and aggresive power saving might be an issue. I will try two possible solutions over a couple of days, will report the outcome. – Znarkus Feb 12 '15 at 22:46
  • Well. i've just tried to see if that policy applies to DHCP packets by reducing dhcpd release time to 3 mins. no luck. it applies to dhcp as well. if you find any working way please answer. – risyasin Feb 12 '15 at 22:56
5

The best solution I could come up with is to nmap -p 62078 IP-ADDRESS | grep "62078/tcp open". If the iPhone is not seen in 60 minutes, it is marked as away.

See https://github.com/Znarkus/homie/blob/master/iphone.js

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.