NetworkExtension's DNS question

I've implemented a custom VPN using NetworkExtension, and the TUN had been set as default gateway, "8.8.8.8" as the DNS server.

Here's my code:


    NEPacketTunnelNetworkSettings *settings = [[NEPacketTunnelNetworkSettings alloc] initWithTunnelRemoteAddress:vpnServerIP];
    settings.IPv4Settings = [[NEIPv4Settings alloc] initWithAddresses:addresses subnetMasks:subnetMasks];
    NEIPv4Route *defaultRoute = [NEIPv4Route defaultRoute];
    NEIPv4Route *localRoute = [[NEIPv4Route alloc] initWithDestinationAddress:localGW subnetMask:gwNetMask];
    settings.IPv4Settings.includedRoutes = @[defaultRoute, localRoute];
    settings.IPv4Settings.excludedRoutes = otherIPs;
    settings.DNSSettings = [[NEDNSSettings alloc] initWithServers:dnsServers];



Now I want some traffic goes through VPN, others goes through ISP's gateway. But most domain still use ISP's DNS server except some custom domains.
Can anyone point me to the right direction?

Replies

Check out this post.

Share and Enjoy

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

let myEmail = "eskimo" + "1" + "@apple.com"