FRP 转发本地 ADB 实现安卓远程调试
通信过程
| ADB CLIENT | | FRP SERVER | | FRP CLIENT | | ANDROID DEVICE |
| | | 5554 | <----> | RAND PORT1 | | |
| RAND PORT | <----> | 5555 | | RAND PORT2 | <----> | 5555 |
服务端安装
5554
端口用于 FRP 自身通信,5555
端口用于 ADB 通信。
# CentOS 7 x64
# 下载程序并解压
cd /usr/local/share
curl -LO https://github.com/fatedier/frp/releases/download/v0.35.1/frp_0.35.1_linux_amd64.tar.gz
tar xzvf frp_0.35.1_linux_amd64.tar.gz
rm -f frp_0.35.1_linux_amd64.tar.gz
mv frp_0.35.1_linux_amd64 frp
cd frp
# 修改配置
cat > frps.ini <<EOF
[common]
bind_port = 5554 ; FRP 端口
token = your-token ; FRP 密码
tcp_mux = false
EOF
# 添加自启服务
cat > /etc/systemd/system/frp.service <<EOF
[Unit]
Description=Frp Service
Requires=network-online.target
[Service]
Type=simple
PIDFile=/run/frp.pid
ExecStart=/usr/local/share/frp/frps -c /usr/local/share/frp/frps.ini
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now frp
# 开启防火墙
firewall-cmd --zone=public --add-port=5554/tcp,5555/tcp --permanent
firewall-cmd --reload
客户端使用
下载并解压 frp_0.35.1_windows_amd64.zip,修改 frpc.ini
为以下内容:
[common]
server_addr = logi.im ; FRP 地址
server_port = 5554 ; FRP 端口
token = your-token ; FRP 密码
tcp_mux = false
[adb]
type = tcp
local_ip = 192.168.2.177 ; 安卓设备 IP
local_port = 5555 ; 安卓设备 ADB 端口
remote_port = 5555 ; FRP ADB 转发端口
随后在本文件夹打开终端,使用以下命令启动:
❯❯ current 17:38 .\frpc.exe -c .\frpc.ini
2021/02/07 17:38:53 [I] [service.go:290] [e325feef865964cc] login to server success, get run id [e325feef865964cc], server udp port [0]
2021/02/07 17:38:53 [I] [proxy_manager.go:144] [e325feef865964cc] proxy added: [adb]
2021/02/07 17:38:53 [I] [control.go:180] [e325feef865964cc] [adb] start proxy success
异地访问安卓设备
❯❯ ~ 17:40 adb connect logi.im
* daemon not running; starting now at tcp:5037
* daemon started successfully
connected to logi.im:5555
❯❯ ~ 17:40 adb devices
List of devices attached
logi.im:5555 device
当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »