iOS PacketTunnelProvider fails when using IPv6 DNS Server

I've implemented a PacketTunnelProvider for iOS. When I set an IPv4 address as the tunnel's DNS server, everything works as expected: all DNS queries from the device are sent through the tunnel. However, when I try to use an IPv6 address, no queries are sent (in fact, no IPv6 packets are sent at all) and the device is unable to resolve domain names.

Here's the relevant code:

let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "1.2.3.4")

let settings4 = NEIPv4Settings(addresses: ["192.128.1.2"], subnetMasks: ["255.255.255.255"])
settings4.includedRoutes = [NEIPv4Route.default()]
settings4.excludedRoutes = []
settings.ipv4Settings = settings4

let settings6 = NEIPv6Settings(addresses: ["2001:4860:123:456::"], networkPrefixLengths: [64])
settings6.includedRoutes = [NEIPv6Route.default()]
settings6.excludedRoutes = []
settings.ipv6Settings = settings6

// If I use this DNS server, everything works normally
//let dnsSettings = NEDNSSettings.init(servers: ["8.8.8.8"])
// With this DNS server, no DNS queries are sent through the tunnel
let dnsSettings = NEDNSSettings.init(servers: ["2001:4860:4860::8888"])
dnsSettings.matchDomains = [""]
settings.dnsSettings = dnsSettings

There are many things that could be going on here so it's hard to provide concrete advice one way or another. Here are at least a few things to check:

  • Try running this on a known Wi-Fi network that supports both v4 and v6. If you are trying this on a cellular network, possibly both paths are not yet available at the time the tunnel comes up so it's good to prove that this works with v6 on a known Wi-Fi network.
  • Make sure that the network you are using supports address translation. See more about this here.
  • Create a test app that just makes connections on your known v6 Wi-Fi network to the v6 endpoints you have provided to verify that it works.
iOS PacketTunnelProvider fails when using IPv6 DNS Server
 
 
Q