Android VpnService. Why is all traffic going through the TUN device?

I created a TUN device using VpnService . Why is the TUN interface the highest priority among the other network interfaces of my device?

Update # 1

Here's how I tuned the TUN device:

mInterface = new Builder().setSession(getString(R.string.app_name)) .addAddress("10.0.1.1", 24) .addRoute("0.0.0.0", 1) .addRoute("128.0.0.0", 1) .establish(); 

Update # 2

This is the result of route -n without a TUN device:

 shell@m0 :/ $ busybox route -n busybox route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.197.55.0 0.0.0.0 255.255.255.0 U 0 0 0 rmnet0 

This is the output of route -n with a TUN device:

 shell@m0 :/ $ busybox route -n busybox route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0 10.197.55.0 0.0.0.0 255.255.255.0 U 0 0 0 rmnet0 shell@m0 :/ $ 
+5
source share

Source: https://habr.com/ru/post/1213551/


All Articles