NEProxySettings and UDP traffic

Hi,

I'm new to iOS development and would like to gain some understanding about how NEPacketTunnelProvider handles for UDP traffic.

In my code, I've created NEPacketTunnelNetworkSettings

let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: proxyHost)

let ipv4Settings = NEIPv4Settings(
    addresses: ["127.0.0.1"],
    subnetMasks: ["255.255.255.255"]
)
settings.ipv4Settings = ipv4Settings

let proxySettings = NEProxySettings()
...
settings.proxySettings = proxySettings

and passed it to the setTunnelNetworkSettings function. And I was able to start the VPN with no issues.

However, in the debug tool, I couldn't see any UDP traffic which I'm sure there should be some. The only UDP connection had no traffic constantly.

Does the NEProxySettings only work for TCP? What am I missing here? (I've set protocolConfiguration?.includeAllNetworks = true in my NETunnelProviderManager)

Thanks

I fear you’re heading down the wrong path here. Packet tunnel providers are intended to provide a VPN service based on either the destination IP or source app (the latter being one flavour of per-app VPN). In those cases you don’t need to monkey with proxy settings. The vast majority of times I see folks having proxy problems with their VPN, especially when using localhost as the proxy, it’s because they’re using a packet tunnel provider for a purpose for which it was never intended. That generally doesn’t end well, to the point that DTS has stopped support such things.

For more on this, see TN3120 Expected use cases for Network Extension packet tunnel providers.

Share and Enjoy

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

Thanks for the information. I've now changed my code to relay network traffic to a remote server. I could only see the traffic going out but not the other way around. I was able to capture the UDP datagrams returning to my phone though. What could be the reasons for this to happen?

The NEPacketTunnelNetworkSettings look like below:

        settings.mtu = 1500
        settings.ipv4Settings = {
            let settings = NEIPv4Settings(addresses: ["192.18.0.1"], subnetMasks: ["255.255.255.0"])
            settings.includedRoutes = [NEIPv4Route.default()]
            return settings
        }()

Sorry. Wrong question. Please ignore. There wasn't network traffic returning back to the NEPacketTunnelProvider.

NEProxySettings and UDP traffic
 
 
Q