Flush DNS cache on iOS

Is it possible to flush DNS cache on iOS?

I'm using NEDNSProxyProvider for redirecting traffic to our DNS server. But when I am changing our DNS server address to OpenDNS method handleNewFlow(_:) doesn't called on previously visited sites.

Replies

Is it possible to flush DNS cache on iOS?

There is no specific API to flush the DNS cache.

I'm using NEDNSProxyProvider for redirecting traffic to our DNS server. But when I am changing our DNS server address to OpenDNS method

handleNewFlow(_:)
doesn't called on previously visited sites.

Can you walk me through this scenario in more detail?

Share and Enjoy

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

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

NEDNSProxyProvider started -> opened "example.com" in Safari -> called handleNewFlow(_:)


handleNewFlow(_:) will not be called if I'll try to open web page again.

I’m sorry I wasn’t clear. I’m looking for information as to why your setup requires you to flush the DNS cache. How are entries getting cached such that they need to be invalidated?

Share and Enjoy

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

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

I'm guessing @Asieiev's scneario is this:


1. user visit example.com. this DNS entry is cached

2. user turns on the app which uses NEDNSProxyProvider, which specifies a custom DNS server

3. user visits example.com again. instead of using the custom DNS server to get a new value, the value cached from step 1 is used.


He would like to programatically clear the DNS cache between steps 2 and 3.

I'm implementing a NEDNSProxyProvider and I have the same issue, I would like to be able to manipulate the DNS cache at some level, this is a possible scenario:


1. user turns on the app which uses NEDNSProxyProvider, which specifies a custom DNS server based on some rules.

2. user visit example.com. this DNS entry is cached

3. the rules are changed.

4. user visits example.com again but the request is cached, the DNS requests never hits the NEDNSProxyProvider so the new rules are not applied until the DNS record TTL is expired.


I'm going to open an improvement request.

  • did anyone manage to solve this? If so, how?

    I have exactly the same problem, albeit on tvOS.

Add a Comment

Hi,

i hade same issue, and it is very easy tu flush on ios.

I just did:

  1. Open Terminal (Application › Utilities › Terminal or click Go > Utilities > Terminal).
  2. Type sudo killall -HUP mDNSResponder and press Enter to run the command.
  3. Enter your password (it might not appear on the screen as you type).


But it depends on your OS system easy fix for all mac systems on https://geeksadvice.com/flush-dns/

The post is about iOS, not macOS