remote-android / redroid-doc

redroid (Remote-Android) is a multi-arch, GPU enabled, Android in Cloud solution. Track issues / docs here
4.15k stars 299 forks source link

如何开启IPv6接入? #616

Open xfl12345 opened 7 months ago

xfl12345 commented 7 months ago

docker-compose.yml

version: '3'
services:
  redroid:
    sysctls:
      - net.ipv6.conf.all.disable_ipv6=0
    container_name: redroid_a13
    image: redroid/redroid:13.0.0-arm64
    privileged: true
    volumes:
      - ~/redroid/data:/data
    network_mode: bridge
    ports:
      - "5555:5555"
    command: androidboot.redroid_gpu_mode=host androidboot.use_memfd=1 androidboot.redroid_width=1080 androidboot.redroid_height=1920 androidboot.redroid_fps=120
    restart: always
PS C:\Users\xfl888> adb shell
redroid_arm64:/ $ ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope: Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:5 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:200 TX bytes:200

eth0      Link encap:Ethernet  HWaddr 02:42:ac:18:00:02
          inet addr:172.24.0.2  Bcast:172.24.255.255  Mask:255.255.0.0
          inet6 addr: fe80::82d6:9fb7:e0af:7eee/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1431 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1342 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:306140 TX bytes:2191999

redroid_arm64:/ $

busybox测试

version: '3'
services:
  busybox_test:
    container_name: busybox-test
    image: busybox
    network_mode: bridge
    command: ifconfig

输出

root@radxa-rockpi-4b-plus:~/my_docker/busybox-test# docker-compose up
Starting busybox-test ... done
Attaching to busybox-test
busybox-test    | eth0      Link encap:Ethernet  HWaddr 02:42:AC:11:00:02  
busybox-test    |           inet addr:172.17.0.2  Bcast:172.17.255.255  Mask:255.255.0.0
busybox-test    |           inet6 addr: fe80::42:acff:fe11:2/64 Scope:Link
busybox-test    |           inet6 addr: fd00:0:0:ffff::2/90 Scope:Global
busybox-test    |           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
busybox-test    |           RX packets:2 errors:0 dropped:0 overruns:0 frame:0
busybox-test    |           TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
busybox-test    |           collisions:0 txqueuelen:0 
busybox-test    |           RX bytes:320 (320.0 B)  TX bytes:110 (110.0 B)
busybox-test    | 
busybox-test    | lo        Link encap:Local Loopback  
busybox-test    |           inet addr:127.0.0.1  Mask:255.0.0.0
busybox-test    |           inet6 addr: ::1/128 Scope:Host
busybox-test    |           UP LOOPBACK RUNNING  MTU:65536  Metric:1
busybox-test    |           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
busybox-test    |           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
busybox-test    |           collisions:0 txqueuelen:1000 
busybox-test    |           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
busybox-test    | 
busybox-test exited with code 0
root@radxa-rockpi-4b-plus:~/my_docker/busybox-test# 
version: '3'
services:
  busybox_test:
    container_name: busybox-test
    image: busybox
    network_mode: bridge
    command: ping6 -c 4 www.taobao.com

输出

root@radxa-rockpi-4b-plus:~/my_docker/busybox-test# docker-compose up
Recreating busybox-test ... done
Attaching to busybox-test
busybox-test    | PING www.taobao.com (2408:8756:4cff:f01c:3::3e2): 56 data bytes
busybox-test    | 64 bytes from 2408:8756:4cff:f01c:3::3e2: seq=0 ttl=56 time=12.041 ms
busybox-test    | 64 bytes from 2408:8756:4cff:f01c:3::3e2: seq=1 ttl=56 time=12.334 ms
busybox-test    | 64 bytes from 2408:8756:4cff:f01c:3::3e2: seq=2 ttl=56 time=12.603 ms
busybox-test    | 64 bytes from 2408:8756:4cff:f01c:3::3e2: seq=3 ttl=56 time=11.338 ms
busybox-test    | 
busybox-test    | --- www.taobao.com ping statistics ---
busybox-test    | 4 packets transmitted, 4 packets received, 0% packet loss
busybox-test    | round-trip min/avg/max = 11.338/12.079/12.603 ms
busybox-test exited with code 0
root@radxa-rockpi-4b-plus:~/my_docker/busybox-test# 

可以确定,我确实是正确配置了 docker 的 IPv6 环境。但是 redroid 似乎不支持 IPv6 接入。

zhouziyang commented 7 months ago

Only ipv4 configs are added in redroid currently. Well, you can manually add ipv6 network configs (address, route etc.). I'm not sure any command to specify ipv6 dns.

zhouziyang commented 7 months ago

BTW, why ipv6 is required here?

xfl12345 commented 7 months ago

BTW, why ipv6 is required here?

Because it is simple. Just make it become a server without NAPT. And i have IPv6-Only web site. I need to make it to be "IPv6 reachable".

xfl12345 commented 7 months ago

Only ipv4 configs are added in redroid currently. Well, you can manually add ipv6 network configs (address, route etc.). I'm not sure any command to specify ipv6 dns.

I was trying to switch the container networking type from "bridge" to "host". Then i found the fact - Android is not support DHCPv6 but SLACC only. It was finally obtain an IPv6 address and ruin mine host network as cost.

zhouziyang commented 7 months ago

Should not use host network mode, otherwise your host networking might be messed up.\

Take a look at https://github.com/remote-android/vendor_redroid/blob/8b2ad82cd7fa0fb1db927542b44c9c84594e93b9/ipconfigstore/main.cc and https://android.googlesource.com/platform/frameworks/base/+/93edcc139722cc6c3f8dc3368846ae364d8ae82d/services/core/java/com/android/server/net/IpConfigStore.java I think it's feasible to add ipv6 support.