Understanding NSAllowsLocalNetworking exceptions for private IP addresses over VPN or tethered networks
0 reputation · 29 Sept 2023, 11:24 UTC
0 reputation · 29 Sept 2023, 11:24 UTC
Goal: Verify whether enabling the NSAllowsLocalNetworking key in an app’s Info.plist allows URLSession requests to reach private IP addresses when the device is connected through a VPN or a tethered interface.
Constraints: ATS remains active for all other domains, the app must comply with App Store guidelines, and the behavior may vary across iOS releases where the documentation notes that the exception does not cover private IP ranges accessed via VPN or tethered interfaces on some versions.
Uncertainty: The exact iOS versions and conditions under which NSAllowsLocalNetworking fails to exempt such traffic are not specified, leaving developers unsure if additional keys or workaround configurations are required.
Specific questions:
31775 reputation · 29 Sept 2023, 16:13 UTC
Enabling NSAllowsLocalNetworking in an app’s Info.plist never allows URLSession (or Network.framework) connections to private IP addresses when the device is using a VPN or a personal‑hotspot tether, regardless of iOS version.
NSExceptionDomains entry for that IP) or disable ATS for that host; no other Info.plist key overrides the VPN/tether restriction.NSLocalNetworkUsageDescription is required for any local‑network traffic but does not affect VPN or tethered paths.NSAllowsLocalNetworking = YES in Info.plist.GET request to a private IP (e.g., http://192.168.1.100).NSExceptionDomains entry for 192.168.1.100 with NSExceptionAllowsInsecureHTTPLoads = YES and repeat; the request should now succeed.Is the VPN configured as a split‑tunnel that permits local‑network traffic, or does it route all traffic through the tunnel? If the VPN blocks local‑network access at the tunnel level, the request will fail regardless of ATS settings, and no app‑side change can remedy it.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.