Skip to content

Instantly share code, notes, and snippets.

@symant233
Created January 25, 2026 13:26
Show Gist options
  • Select an option

  • Save symant233/70bd9a7c9e398004f6885835a9fa5ac8 to your computer and use it in GitHub Desktop.

Select an option

Save symant233/70bd9a7c9e398004f6885835a9fa5ac8 to your computer and use it in GitHub Desktop.
sunshine ports forwarding
#!/bin/bash
# 设备 A 的 Tailscale IP
REMOTE_IP="100.100.120.233"
echo "------------------------------------------"
echo "🔍 正在通过 ifconfig 检测本地 IP..."
echo "------------------------------------------"
# 直接使用 ifconfig 过滤显示非本地和非 Tailscale 的 IP
ifconfig | grep "inet " | grep -v "127.0.0.1" | grep -v "100."
echo "------------------------------------------"
echo "💡 提示:请在 Moonlight 中填写上方显示的 192.168.x.x 地址"
echo "🚀 正在启动 Sunshine 转发 -> $REMOTE_IP"
echo "------------------------------------------"
# 清理旧进程
pkill socat > /dev/null 2>&1
# 转发 TCP 端口 (控制信号)
for port in 47984 47989 48010; do
socat TCP4-LISTEN:$port,fork,reuseaddr TCP4:$REMOTE_IP:$port &
done
# 转发 UDP 端口 (视频流)
for port in 47998 47999 48000 48002 48010; do
socat UDP4-LISTEN:$port,fork,reuseaddr UDP4:$REMOTE_IP:$port &
done
echo "✅ 转发服务已启动。"
echo "⚠️ 请确保在 Termux 通知栏开启了 'Acquire wake lock'。"
echo "------------------------------------------"
# 保持脚本运行
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment