Specific DNS for a Android App


Question

I am currently using adguard DNS using the private DNS setting in my android device to avoid advertisements. But it increases the ping time while I am in a multiplayer game (like PUBG Mobile). Is it possible to use different DNS for an app and a common DNS for everything else?



Note: I am currently based in India if location matters for your answer.


Answer

DNS resolution in Android is handled by Net Daemon (netd) which runs in background as an init service. netd uses the DNS server set in Wi-Fi settings or that received through DHCP. Or it can possibly be set through CLI. See details in How does Android OS do DNS name resolution?. But there is no way to specify DNS server on per app basis.



Using Android's VPNService API it's possible to control network traffic on per UID basis (every Android app owns a unique UNIX UID). Or with root access the same can be achieved using iptables to NAT traffic going on port 53. An example VPN based open-source app which lets whitelist apps and configure DNS server is personalDNSfilter (I have no affiliation). It's configurable enough and supports root mode, encrypted DNS (DoH, DoT) and other features.



However in both cases (VPN or iptables), you won't be able to use Android's Private DNS (DoT) feature. It's because DoT (DNS over TLS) queries aren't plain DNS (like HTTP) but encrypted (like HTTPS), going on port 853. So the only entity that can receive and respond to the encrypted DNS queries is the DNS server set in Private DNS settings. Though it's possible to intercept DoT (like we can intercept HTTPS) but the hassle doesn't worth a try.



If you don't want to go with VPN or root based solutions, or don't want to leave Private DNS, another option is to setup DNS forwarder on local network, preferably on default gateway if possible. Or your app must itself have capability to make DNS queries, not depending on Android's resolver.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes