Skip to content
Foxnet-LabPublic

About

Rootless Android userspace USB Ethernet tether (IPv4 + IPv6)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

EthBridge

Rootless, VpnService-free Android userspace USB Ethernet tether (ngo.xnet.ethbridge).

EthBridge claims a USB Ethernet adapter in Android USB Host Mode—driving Realtek RTL8152/8153 adapters directly on Config 1 via USBDEVFS_CONTROL / USBDEVFS_SUBMITURB (falling back to CDC-ECM when available)—and forwards dual-stack IPv4 and IPv6 traffic through an embedded hev-socks5-tunnel + lwIP userspace stack pinned to the cellular network (android_setsocknetwork()).

Features

  • No root, no VpnService, no TetheringManager/DUN — operates purely in app userspace over UsbDeviceConnection file descriptors.
  • Native RTL8152/8153/8156 Config 1 driver (r8152-usb.c) — avoids Config 2 USB resets and r8152-cfgselector snap-back on Pixel devices, with automatic CDC-ECM fallback.
  • Dual-stack IPv4 + IPv6 with dynamic upstream DNS:
    • IPv4: 10.200.0.1/24 gateway, built-in ARP + DHCPv4 server (10.200.0.2–10.200.0.250, Option 6 populated from active upstream LinkProperties DNS with 1.1.1.1/8.8.8.8 fallback), unprivileged IPPROTO_ICMP echo relay, and TCP/UDP forwarding.
    • IPv6: EUI-64 link-local gateway + fd00:c800::1/64 ULA, SLAAC Router Advertisements (prefix fd00:c800::/64, MTU 1428, RDNSS populated from active upstream DNS with 2606:4700:4700::1111/2001:4860:4860::8888 fallback), NDP NS/NA, unprivileged IPPROTO_ICMPV6 echo relay, and IPv6 TCP/UDP forwarding.
  • Edge-to-edge Android 15+ UI & strict native build: enableEdgeToEdge() + WindowInsetsCompat padding, -Wall -Wextra -Werror enforced on custom C sources (ethbridge_custom), and 16 KB (0x4000) ELF alignment verification in scripts/build-native.sh.
  • Integrated line-speed test server (eth-speedtest.c): Built-in HTTP/1.1 (:5201) and raw TCP (:5202 DL / :5203 UL) benchmark endpoints on 10.200.0.1 and [fd00:c800::1] (zero cellular traffic) plus live Mbps & benchmark readouts in the app UI.

Integrated Line Speedtest

With the bridge active, run from the tethered host (zero cellular data used):

# Web UI (browser)
http://10.200.0.1:5201/

# HTTP Download / Upload (IPv4)
curl -o /dev/null -w '%{speed_download} B/s\n' 'http://10.200.0.1:5201/down?bytes=50000000'
dd if=/dev/zero bs=1M count=50 status=none | curl -T - http://10.200.0.1:5201/up

# HTTP Download / Upload (IPv6)
curl -6 -o /dev/null -w '%{speed_download} B/s\n' 'http://[fd00:c800::1]:5201/down?bytes=50000000'
dd if=/dev/zero bs=1M count=50 status=none | curl -6 -T - 'http://[fd00:c800::1]:5201/up'

# Raw TCP streams & JSON stats
nc 10.200.0.1 5202 >/dev/null
dd if=/dev/zero bs=1M count=50 status=none | nc -N 10.200.0.1 5203
curl -s http://10.200.0.1:5201/stats

Notes:

  • The server is LAN-local only (listens only on 10.200.0.1 / fd00:c800::1) and deliberately constrained: at most 8 concurrent sessions and 30 s per test, so a tethered client can't hold resources indefinitely. Raw-TCP downloads run for up to 30 s regardless of ?bytes=; HTTP downloads honor ?bytes= or ?sec= (capped at 1 GB / 30 s).
  • Benchmark readouts (/stats last_dl_mbps / last_ul_mbps and the app's "Bench" line) are only updated for transfers of at least 64 KB; short ?bytes= probes count toward the live counters but not the recorded benchmark.

Repository Layout

  • app/ — Android Kotlin application (MainActivity, EthTetherService, CdcEcmUsbHelper, EthBridgeNative, XML resources & adaptive icons).
  • native/tunnel/ — Native C/NDK sources (eth-bridge.c, r8152-usb.c, hev-jni.c, hev-socks5-session.c, hev-socks5-tunnel, lwip, hev-task-system, yaml).
  • scripts/build-native.sh — Builds libethbridge.so (arm64-v8a), checks 16 KB ELF LOAD alignment, and copies it into app/src/main/jniLibs/arm64-v8a/.

Building from Source

# 1. Build native library (requires Android NDK)
./scripts/build-native.sh

# 2. Build debug APK (requires JDK 21 and Android SDK)
JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64 ANDROID_HOME=~/android-sdk ./gradlew assembleDebug --no-daemon

About

Rootless Android userspace USB Ethernet tether (IPv4 + IPv6)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages