iOS reports incorrect own IP address to apps when connected to WiFi

I have an iPhone app which relies heavily on TCP/IP communication in the local network. Therefore, the application starts a server socket and accepts incoming connections. This worked flawlessly for a long time and we had no problems with this.

Problem

In the last days however, we observed that for some iPhones with the server role other devices cannot connect to the server of our app. The server does not accept incoming connections on the devices IP address and the client times out.

Environment

Both iPhones (the server and the client) are in the same network with 192.168.1.0 address range and 255.255.255.0 subnet mask. The server has the IP 192.168.1.11 and the client has 192.168.1.22. This is a normal home WiFi network with no special firewall rules. Both devices have mobile data disabled and the "access local network" permission is granted. The server socket is bound to all interfaces (0.0.0.0).

More technical symptoms

When the server iPhone is in this faulty state, it seems like it somehow has two ip addresses:
192.168.2.123 and 192.168.1.11

The WiFi preferences show the (correct) .1.11 ip address. The Apps however see the (wrong) .2.123 ip address. I cannot explain where the other ip address comes from and why the device thinks it has this ip address.

I've collected interface diagnosis information on a faulty iPhone and it listed the following interfaces and IPs:

  • en0 -> 192.168.2.123
  • lo0 -> 127.0.0.1
  • pdp_ip0 (cellular) -> 192.0.0.2
  • pdp_ip1 to pdp_ip6 (cellular) -> -/-
  • ipsec0 to ipsec6 (vpn) -> -/-
  • llw0 (vpn) -> -/-
  • awdl0 -> -/-
  • anpi0 -> -/-
  • ap1 -> -/-
  • XHC0 -> -/-
  • en1 and en2 (wired) -> -/-
  • utun0 to utun2 (vpn) -> -/-

The correct ip of the device is not listed anywhere in this list.

A reboot helped to temporarily fix this problem. One user reported the same issue again a few hours later after a reboot. Switching off WiFi and reconnecting does not solve the problem.

This issue occurred on several iPhones with the following specs:

  • iOS Version 18.1.1, 18.3.1
  • iPhone 13 Pro, iPhone 13 Pro Max, iPhone 15 Pro

The problem must be on the server side as the client can successfully connect to any other device in the same network.

Question(s)

  • Where does this second IP come from and why does the server not accept connections to either ip even though it is bound to 0.0.0.0?
  • Are there any iOS system settings which could lead to this problem? (privacy setting, vpn, ...)
  • What could be done to permanently fix this issue?

Some general resources:

Written by Bennik2000 in 775528021
I've collected interface diagnosis information on a faulty iPhone

How did you generate the list of interfaces to report? With getifaddrs?

Share and Enjoy

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

iOS reports incorrect own IP address to apps when connected to WiFi
 
 
Q