someuser
someuser

Reputation: 1

How do I implement an Android VPN App with Local DNS resolver

Is it possible to make an Android VPN app, using VpnService.addDnsServer, and have DNS queries go to my own autonomous DNS resolver server listening on my phone's 127.0.0.1:5353 port?

Here is my code slice.

        val builder = Builder()
            .setSession("my VPN app")
            .setMtu(1500)
            .addAddress("192.168.10.3", 24)
            .addDnsServer("127.0.0.1")

But it not works with Bad address. other ways when my DNS server listen on 127.0.0.1:53, it's failed with Permission denied (os error 13), so I have to listen on 127.0.0.1:5353.

If I using .addDnsServer("127.0.0.1:5353") call, the App will crash with Not a numeric address: 127.0.0.1:5353.

I have tried .addDnsServer("192.168.10.1"), it not work alse. my DNS server can not run at 192.168.10.1:53 with error Cannot assign requested address (os error 99).

I also tried .addDnsServer("192.168.10.3"), and run my DNS server at 192.168.10.3:53, but failed with Permission denied (os error 13). This time I can run DNS server at 192.168.10.3:5353, but it's not my purpose yet, it's useless.

So, How I do it?

Any suggestions are greatly appreciated.

Upvotes: 0

Views: 176

Answers (1)

someuser
someuser

Reputation: 1

Now it seems that this is a dead end with no solution. Unless the Android team changes this part of the code logic.

The current situation is that if I ignore the localization of this DNS resolver and specify a random one such as 8.8.8.8, it works in most cases. There is only one situation where it does not work, and that is the Youtube Android App. It can work normally at the beginning, such as getting the home page and getting video information, but when playing a video, after 3 minutes, it can no longer continue to play.

I can't think of any other possibility except DNS issues.

Because China's GFW will block certain DNS queries sent to 8.8.8.8 for they are in plaintext. This is easy to identify.

Upvotes: 0

Related Questions