I am trying to run a VPN server on iOS to redirect DNS traffic to my preferred DNS server. I understand Apple has provided TunnelServer in SimpleTunnelCustomizedNetworkingUsingtheNetworkExtensionFramework but it can be executed on OSX not iOS. What do I need to do to run the VPN server on iOS devices?
Please understand that under iOS, general purpose indefinite duration tasks are not supported. Your VPN server is going to die when its background process runs out of time. Any work around you find for this is going to be the result of misusing the existing background task system, and make the app you develop inelligible for submission to the App Store.
So you have two choices:
1. If you want a VPN server that is going to die when you put in the background, but that's okay because you're just using it to test things, then you can get a VPN server running on iOS. The results of this choice can be discussed here.
2. If you want a VPN server that isn't going to die when you put it in the background, you have to do things that either violate the Developer guidelines or use a non-standard iOS device. The results of this choice cannot be discussed here.
That's why Apple doesn't provide a VPN server for iOS devices.
On the other hand, you should be able to accomplish the task you've set out to do, redict DNS traffic to your preferred DNS server, by implementing an VPN client or creating a personal VPN configuration to use the specified DNS server.