My question is when the vpn is on and the network changes, I did not found a way to get the new network's default DNS server, res_9_getservers returns the dns server which I was setting up.
So how can I get the new DNS when network changes?
Thank you!
Because trying to get all of the DNS traffic to route through your tunnel is an endless scenario of edge cases and gotchas. We have specific APIs to handle capturing all DNS traffic in the way that you see fit. Trying to account for scenario's where NEDNSSettings is setup to capture ALL DNS traffic usually ends up in a breakdown of some sort because certain browser based queries ultimately slip outside your match domain settings.Why?
Right. So if you do not have any other routes on the system to handle DNS, then the VPN's route will act as a backstop to handle the DNS traffic and the servers used in NEDNSSettings will be used to do so. This does not mean that this is a recommended course of action and it will not always be the case on every device or machine. You will need to look at the routing table to know for sure, but it could be the case where mDNSResponder is using a different route to handle your DNS traffic.What about this description "If the VPN tunnel becomes the network’s default route,
the servers listed earlier by NEDNSSettings become the default resolver and the
matchDomains list is ignored."
Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com