For creating NEPacketTunnelNetworkSettings settings I am using the bellow code.
In this code I am only adding "8.8.8.8", "1.1.1.1" in IPV4 includedRoutes and , "2001:4860:4860::8888" IPV6 includedRoutes. excludedRoutes are default.
But I am getting some packets from 17.130.21.5:443 this IP.
- (NEPacketTunnelNetworkSettings *)createTunnelSettings {
NEPacketTunnelNetworkSettings *settings = [[NEPacketTunnelNetworkSettings alloc] initWithTunnelRemoteAddress:@"127.1.1.1"];
NEIPv4Settings *ipv4 = [[NEIPv4Settings alloc]
initWithAddresses:@[@"172.16.209.2"]
subnetMasks:@[@"255.255.255.252"]];
NEIPv6Settings *ipv6 = [[NEIPv6Settings alloc]
initWithAddresses:@[@"fd12:1:1:1::2"]
networkPrefixLengths:@[ @(64)]];
NEDNSSettings * dns = [[NEDNSSettings alloc] initWithServers: [@"8.8.8.8", @"1.1.1.1",@"2001:4860:4860::8888"]];
NSMutableArray* ipv4IncludedRoutes = [NSMutableArray new];
[ipv4IncludedRoutes addObject:[[NEIPv4Route alloc] initWithDestinationAddress:@"8.8.8.8"
subnetMask:@"255.255.255.255"]];
[ipv4IncludedRoutes addObject:[[NEIPv4Route alloc] initWithDestinationAddress:@"1.1.1.1"
subnetMask:@"255.255.255.255"]];
NSMutableArray* ipv6IncludedRoutes = [NSMutableArray new];
[ipv6IncludedRoutes addObject:[[NEIPv6Route alloc] initWithDestinationAddress:@"2001:4860:4860::8888"
networkPrefixLength: @(128)]];
ipv4.includedRoutes = ipv4IncludedRoutes;
ipv6.includedRoutes = ipv6IncludedRoutes;
ipv4.excludedRoutes = @[[NEIPv4Route defaultRoute]];
ipv6.excludedRoutes = @[[NEIPv6Route defaultRoute]];
dns.matchDomains = @[ @"" ];
settings.DNSSettings = dns;
if(ipv4Available) {
settings.IPv4Settings = ipv4;
}
if(ipv6Available) {
settings.IPv6Settings = ipv6;
}
}
return settings;
}