Search code examples
androiddnsandroid-vpn-service

Is this possible to set Custom IP for DNS server in the Wifi Settings from my Android App?


I'm trying to set DNS to the Wifi and 4G data, So that i can use my Custom DNS server by which all my data will through my own server.

By researching in internet i saw it's dificult to set for the application. But i saw some app are still in the Play store.


Solution

  • No, it is not possible to directly set a custom IP for the DNS server in the Wi-Fi settings from within your Android app. Android does not provide a public API that allows apps to modify the DNS settings of the device programmatically.

    The DNS settings of the device are managed at the system level and can only be modified by the user or by system-level configurations. As an app developer, you do not have direct control over these settings.

    However, you can guide users on how to manually change their DNS settings by directing them to the device's Wi-Fi settings page. You can provide instructions or open the Wi-Fi settings page using an intent, but the actual modification of the DNS settings has to be done by the user manually.

    Keep in mind that modifying DNS settings can have system-wide effects, so it is generally recommended to let users manage their DNS settings themselves unless your app specifically requires DNS configuration for its functionality.