nmap it is possible to check if an iPhone is available in the network even so.
At least execute 3 times following:
sudo nmap -PO -sU -p5353 -Pn <ip-address> | grep "1 host up" | wc -l
The best way is to regularly do this UDP ping and then e.g. if the phone doesn't reply even after
x minutes it is set to be away. This is handy for presence detection in smart homes.
Just to document, before I used
sudo -s '<cmd>' but this did produce an
/bin/bash <cmd> No such file or directory, now I need to use
sudo bash -c '<cmd>' to achieve that the command
<cmd> is run correctly