Getting device's local IP address via mDNS in iOS 17 betas.

I have iPhone named myphone. To get its IP address on local network, I used to do do host myphone.local in Terminal, or just checking if it is alive by ping myphone.local. This basic mDNS function worked every time, but with iOS 17 betas it is not working anymore. Is this intended functionality cut or just a bug?

Answered by DTS Engineer in 762421022

Note that Apple TV always has registered services, so the local DNS name records are always registered. And IIRC this behaviour is disabled on macOS, so you’ll always see the local DNS name records for Macs as well.

Maybe I can register some Bonjour service on Macbook or Linux, so iPhone will respond by name if it in local network?

I don’t understand this. How would registering a service on macOS change the behaviour of iOS?

I am working on home automation project that need to detect the presence of certainly named device in the local network.

Bonjour works in terms of services, not devices, which explains the problem you’re having here. If the iOS device were registering a service, you could browse the service and you wouldn’t have this issue.

If I were in your shoes I’d ask our DHCP server for the list of its clients.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I am not aware of any changes here; can you see your device in an app like Discovery? Are you in need of connecting to your device from another device on the network and cannot find it via local network name anymore or was this just a debugging step that you used in your workflow?

I don't see in Discovery iPhone with iOS 17 beta, but I do see Apple TV, Macbook Pro, iPhone with iOS 16. Yes, connecting to my device from another device on the local network by name (e.g. myphone.local) no longer works if destination device runs iOS 17 beta.

I know Apple uses mDNSResponder, so I tried to check sources first and discovered that mDNSCore directory became empty, so I decided to ask here what is happening with mDNS subsystem.

This basic mDNS function worked every time

That was not my experience. A while back we changed the mDNS stack on iOS to only register A and AAAA records for the device if someone has registered a Bonjour service that requires them. So this technique would only work if there was a service running, which there usually isn’t.

Indeed, I just tried this with my personal iPhone, running iOS 16.6, and I can ping it by IP address:

% ping 192.168.1.90
PING 192.168.1.90 (192.168.1.90): 56 data bytes
64 bytes from 192.168.1.90: icmp_seq=0 ttl=64 time=70.290 ms

but not by DNS name:

% ping dr-nobel-price.local.
ping: cannot resolve dr-nobel-price.local.: Unknown host

It’s possible that there was something unrelated, like Xcode’s debugging infrastructure, that was previously causing this to work.

Why are you trying to find the iPhone’s IP address from your Mac? I most commonly see this with developers who have an app with a network listener and they want to connect to it for testing. In that case the best solution is to register that listener with Bonjour.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thank you, Quinn.

It's strange that you have different behavior. Maybe your iPhone was sleeping/not unlocked? I just pinged from local Linux box:

  • Wife's iPhone SE, iOS 16.6:
$ ping -W 5 -c 1 katias-iphone.local
PING katias-iphone.local (192.168.50.93) 56(84) bytes of data.
64 bytes from 192.168.50.93 (192.168.50.93): icmp_seq=1 ttl=128 time=36.1 ms
  • Our old Apple TV (A1469), software 7.9(8163):
$ ping -W 5 -c 1 apple-tv.local     
PING apple-tv.local (192.168.50.223) 56(84) bytes of data.
64 bytes from 192.168.50.223 (192.168.50.223): icmp_seq=1 ttl=128 time=18.2 ms
  • My iPad Pro 11" 3rd gen, ipadOS 16.6:
$ ping -W 5 -c 1 filpad.local       
PING filpad.local (192.168.50.73) 56(84) bytes of data.
64 bytes from 192.168.50.73 (192.168.50.73): icmp_seq=1 ttl=128 time=3.81 ms
  • My iPhone 11, iOS 17.0 beta:
$ ping -W 5 -c 1 filphone.local
ping: filphone.local: Name or service not known

I am working on home automation project that need to detect the presence of certainly named device in the local network. Maybe I can register some Bonjour service on Macbook or Linux, so iPhone will respond by name if it in local network?

Accepted Answer

Note that Apple TV always has registered services, so the local DNS name records are always registered. And IIRC this behaviour is disabled on macOS, so you’ll always see the local DNS name records for Macs as well.

Maybe I can register some Bonjour service on Macbook or Linux, so iPhone will respond by name if it in local network?

I don’t understand this. How would registering a service on macOS change the behaviour of iOS?

I am working on home automation project that need to detect the presence of certainly named device in the local network.

Bonjour works in terms of services, not devices, which explains the problem you’re having here. If the iOS device were registering a service, you could browse the service and you wouldn’t have this issue.

If I were in your shoes I’d ask our DHCP server for the list of its clients.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thank you for advice, I will try DHCP method.

How would registering a service on macOS change the behaviour of iOS?

Sorry, just asking while looking for options :)

I think I've found out why other iPhone and iPad are pingable - they advertise _rdlink._tcp.local service (what's that?) while iPhone with iOS17 beta does not. Thank you for your help, Quinn. Very valuable.

I reported it as potential privac issue as it was „leaking” in most cases real user name.

As a result they probably disabled functionality - sorry 🤷🏻‍♂️

Uuuggh. This completely breaks OpenHAB scripting patterns

Mitigation of "leaking real user name in mdns" could have been mitigated with less breakage: .... just anonymize or generalize the announcement.

Getting device's local IP address via mDNS in iOS 17 betas.
 
 
Q