I have extended VpnService
and trying to route all the traffic through it. I am able to connect to vpn successfully as I can see it in the status bar. But when I do so, I am not able to access anything over network. I have checked the sample repos available and I am doing all minimal things that I required to achieve this but it’s still not working for me.
The output for ip route looks like following when vpn is connected.
adb shell ip route
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.2
Sharing the code for vpn builder configuration.
private fun startVpn() {
val builder = Builder()
builder.setSession(getString(R.string.app_name))
.addAddress("10.0.0.2", 32)
.addRoute("0.0.0.0", 0) // Route all IPv4 traffic through the VPN
.addDnsServer("8.8.8.8")
.addDnsServer("8.8.4.4")
try {
vpnInterface = builder.establish()
Timber.d("$LOG_PREFIX: VPN Interface established")
} catch (e: IOException) {
e.printStackTrace()
Timber.d("$LOG_PREFIX: Failed to establish VPN interface: ${e.message}")
stopSelf()
}
}
```
Please help on how to debug this further or fix this.