VPN On-Demand Rules

I work with NetworkExtension.framework these days. And I wanna starting VPN programatically with On-Demand rules, which only forwards specifical IPs through VPN and bypass all the others, does anyone know how to make this work? Thank you all!

Download the simple tunnel sample code, should be evertthing you need in there

Thanks, I have look at this code!

The code you said works for iOS9 and above, is there any code works for iOS8?

When working with NEVPNManager it's best, in my experience, to try and set things up first using a configuration profile. Once you have that working, you can then try to 'port' the settings to your code.

To that end, you should read the VPN sections of Configuration Profile Key Reference. It has an extensive discussion of the on-demand rules.

If you can't get things to work with a configuration profile, you should post over in one of the in Business and Education sections of the Apple Support Communities, run by AppleCare. The folks over there are more likely to have experience in VPN setup issues.

OTOH, if you have a working configuration profile but you can't figure out how to replicate that in NEVPNManager, you should post your follow-up questions here.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
VPN On-Demand Rules
 
 
Q