Hello,
I'm trying to set DNS servers for my packet tunnel but it looks like OS ignores them. Here is how I set DNS servers:
// configrations is a POJO with some tunnel information
NEPacketTunnelNetworkSettings *settings = [[NEPacketTunnelNetworkSettings alloc] initWithTunnelRemoteAddress:configuration.remoteAddr];
settings.IPv4Settings = [[NEIPv4Settings alloc] initWithAddresses:@[configuration.localAddr] subnetMasks:@[@"255.255.255.0"]];
BOOL isFullTunnel = YES;
if (configuration.routes.count > 0) {
// create routes and add them
settings.IPv4Settings.includedRoutes = routes;
isFullTunnel = NO;
} else {
settings.IPv4Settings.includedRoutes = @[[NEIPv4Route defaultRoute]];
}
if (configuration.dnsServers.count > 0) {
settings.DNSSettings = [[NEDNSSettings alloc] initWithServers:configuration.dnsServers];
}
[self setTunnelNetworkSettings:settings completionHandler:^(NSError * _Nullable error) {
// some next actions
}];
When I start packet tunnel, it works fine and OS route networks packets right, but DNS requests go to defaul server (from network interface I guess), not to configured DNS servers.
Here is how it looks like in tcpdump:
375 105.231826 192.168.2.2 192.168.2.1 DNS 72 Standard query 0xf1d6 A web.test
IP address 192.168.2.2 is my iOS device with started packet tunnel and 192.168.1.1 is IP address of device, I connected to by Wi-Fi (Wi-Fi hotspot) and "web.test" is hostname I want to get IP address for. Why OS ignores my DNS servers settings?