redroid-doc icon indicating copy to clipboard operation
redroid-doc copied to clipboard

VPN support

Open intelligentpotato opened this issue 3 years ago • 7 comments

Hello.

It turns out that Redroid in its current state does not support VPN clients, SocksDroid, etc. There are 2 issues:

  • TUN interface is on /dev/net/tun instead of /dev/tun where Android normally looks for it
  • when /dev/tun is there, Operation not permitted or silent system crash depending on the VPN app

Can this be fixed?

Please see https://github.com/remote-android/redroid-doc/issues/259#issuecomment-1798872672

intelligentpotato avatar Nov 07 '23 15:11 intelligentpotato

Might be useful: https://github.com/anbox/anbox/pull/1086

intelligentpotato avatar Nov 07 '23 16:11 intelligentpotato

I just simply add the flag -v /dev/net/tun:/dev/tun to docker, and the tun device becomes available

TeddyNight avatar Nov 07 '23 16:11 TeddyNight

@TeddyNight what redroid version are you using and what command? I just tried

docker run -itd --privileged \
    -v /dev/net/tun:/dev/tun \
    -v ~/data1:/data \
    -p 5551:5555 \
    --name redroid11_1 \
    --restart always \
    redroid/redroid:11.0.0_magisk \
    ro.product.cpu.abilist=x86_64,arm64-v8a,x86,armeabi-v7a,armeabi \
    ro.product.cpu.abilist64=x86_64,arm64-v8a \
    ro.product.cpu.abilist32=x86,armeabi-v7a,armeabi \
    ro.dalvik.vm.isa.arm=x86 \
    ro.dalvik.vm.isa.arm64=x86_64 \
    ro.enable.native.bridge.exec=1 \
    ro.enable.native.bridge.exec64=1 \
    ro.dalvik.vm.native.bridge=libhoudini.so

The emulator just goes offline in a minute or so and keeps printing the following to logcat:

11-07 20:12:43.633   478   478 D InterruptionStateProvider: No heads up: unimportant notification: 0|ch.protonvpn.android|6|null|10134
11-07 20:12:43.634   109   109 D hwcomposer: VSYNC event status:1
11-07 20:12:44.025   109   109 D hwcomposer: VSYNC event status:0
11-07 20:12:44.431   302  1102 E BpfNetworkStats: get ifaceStats map fd failed: Operation not permitted
11-07 20:12:44.431   302  1102 E BpfNetworkStats: get ifaceStats map fd failed: Operation not permitted
11-07 20:12:44.636   478   478 D InterruptionStateProvider: No bubble up: not allowed to bubble: 0|ch.protonvpn.android|6|null|10134
11-07 20:12:44.636   478   478 D InterruptionStateProvider: No heads up: unimportant notification: 0|ch.protonvpn.android|6|null|10134
11-07 20:12:44.638   109   109 D hwcomposer: VSYNC event status:1
11-07 20:12:45.025   109   109 D hwcomposer: VSYNC event status:0
11-07 20:12:45.435   302  1094 E BpfNetworkStats: get ifaceStats map fd failed: Operation not permitted
11-07 20:12:45.435   302  1094 E BpfNetworkStats: get ifaceStats map fd failed: Operation not permitted
11-07 20:12:45.641   478   478 D InterruptionStateProvider: No bubble up: not allowed to bubble: 0|ch.protonvpn.android|6|null|10134
11-07 20:12:45.642   478   478 D InterruptionStateProvider: No heads up: unimportant notification: 0|ch.protonvpn.android|6|null|10134

Thanks again for adding support for libhoudini to redroid btw ;)

UPD: Also tried

docker run -itd --privileged \
	-v /dev/net/tun:/dev/tun \
    -v ~/data0:/data \
    -p 5551:5555 \
    --name redroid11 \
    --restart always \
    --pull always \
    redroid/redroid:11.0.0-latest

Also stuck

11-07 18:01:11.000   762  1023 E TcpSocketTracker: Expect to get family 10 SOCK_DIAG_BY_FAMILY message but get 2
11-07 18:01:11.000   762  1023 E TcpSocketTracker: Expect to get family 2 SOCK_DIAG_BY_FAMILY message but get 2
11-07 18:01:28.519   137   163 E Netd    : Failed to dump IPv4 sockets struct tcp_info: No such file or directory
11-07 18:01:28.519   137   163 E TcpSocketMonitor: Failed to poll TCP socket info: No such file or directory
11-07 18:01:31.020   762  1023 E TcpSocketTracker: Expect to get family 10 SOCK_DIAG_BY_FAMILY message but get 2
11-07 18:01:31.020   762  1023 E TcpSocketTracker: Expect to get family 2 SOCK_DIAG_BY_FAMILY message but get 2
11-07 18:01:51.039   762  1023 E TcpSocketTracker: Expect to get family 10 SOCK_DIAG_BY_FAMILY message but get 2

intelligentpotato avatar Nov 07 '23 17:11 intelligentpotato

@intelligentpotato Oh, I forgot. You may need an extra flag --sysctl net.ipv6.conf.all.disable_ipv6=0. On my server it works because ipv6 is disabled by default inside the cotainer and the VPN app has no permission to add ipv6 addr to tun.

TeddyNight avatar Nov 07 '23 23:11 TeddyNight

@TeddyNight it works! Appreciate your help.

Note to everybody: remember to proxify only specific apps, not the whole system, otherwise you will lock yourself out from scrcpy and adb.

docker run -itd --privileged \
    --cap-add=net_admin --cap-add=net_raw --cap-add=mknod \
    --sysctl net.ipv6.conf.all.disable_ipv6=0 \
    -v /dev/net/tun:/dev/tun \
    -v ~/data:/data \
    -p 5555:5555 \
    --name redroid11 \
    redroid/redroid:11.0.0_magisk \
    ro.product.cpu.abilist=x86_64,arm64-v8a,x86,armeabi-v7a,armeabi \
    ro.product.cpu.abilist64=x86_64,arm64-v8a \
    ro.product.cpu.abilist32=x86,armeabi-v7a,armeabi \
    ro.dalvik.vm.isa.arm=x86 \
    ro.dalvik.vm.isa.arm64=x86_64 \
    ro.enable.native.bridge.exec=1 \
    ro.enable.native.bridge.exec64=1 \
    ro.dalvik.vm.native.bridge=libhoudini.so

intelligentpotato avatar Nov 08 '23 09:11 intelligentpotato

@intelligentpotato tailscale is the way to go in that case, you won't loose connection to your redroid if you are connected through tailscale.

ravichaudhary133 avatar Feb 09 '24 13:02 ravichaudhary133

@intelligentpotato tailscale is the way to go in that case, you won't loose connection to your redroid if you are connected through tailscale.

Hey, How did you managed it? If i add Tailscale it wont connect to a additional VPN

DryTi avatar Mar 01 '24 00:03 DryTi