Files
luci-app-owrt-remote/README.md
T

9.3 KiB

OpenWrt Remote Hub

Удаленный доступ к OpenWrt через свой VPS: красивые карточки роутеров, online/offline, heartbeat, Xray VLESS reverse и вход в LuCI извне без ZeroTier, Tailscale и WireGuard.

Telegram · GitHub · NetHaven VPN

Что это

luci-app-owrt-remote делает схему:

Браузер -> VPS Hub -> локальный Xray entry port -> VLESS reverse tunnel -> LuCI роутера

Роутер сам подключается к VPS изнутри сети и держит reverse-туннель. На VPS открывается веб-панель с карточками роутеров. Нажимаешь Админка и попадаешь в LuCI нужного OpenWrt через VPS.

LuCI роутера напрямую в интернет открывать не нужно.

Возможности

  • Панель VPS: http://YOUR_VPS_IP:8088/.
  • Первый вход: admin / admin.
  • Логин и пароль можно поменять прямо в панели Hub.
  • Несколько роутеров в одной панели.
  • Online/offline по heartbeat.
  • Кнопка Админка для входа в LuCI через VPS.
  • Кнопка OpenWrt config с готовыми UCI-командами для роутера.
  • Кнопка Client JSON с клиентским Xray-конфигом.
  • Легкий агент на OpenWrt: shell + CGI, без тяжелого Lua-приложения.

Установка VPS

Нужен Ubuntu/Debian VPS, Python 3 и Xray.

1. Установить Xray на VPS

sudo apt update
sudo apt install -y curl unzip python3
sudo bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install
xray version || /usr/local/bin/xray version

2. Установить Hub

sudo mkdir -p /opt/owrt-remote /var/lib/owrt-remote /etc/xray
sudo wget -O /opt/owrt-remote/owrt-remote-hub.py "https://raw.githubusercontent.com/kzolotarev95/luci-app-owrt-remote/main/vps/owrt-remote-hub.py"
sudo wget -O /etc/systemd/system/owrt-remote.service "https://raw.githubusercontent.com/kzolotarev95/luci-app-owrt-remote/main/vps/owrt-remote.service"
sudo chmod +x /opt/owrt-remote/owrt-remote-hub.py
sudo systemctl daemon-reload

Создать базу и первый логин:

sudo /opt/owrt-remote/owrt-remote-hub.py init

По умолчанию создается вход:

login: admin
password: admin

Пароль можно сразу сменить:

sudo /opt/owrt-remote/owrt-remote-hub.py set-login --username admin --password 'NEW_PASSWORD'

Запустить Hub:

sudo systemctl enable --now owrt-remote
sudo systemctl status owrt-remote --no-pager -l

Открыть панель:

http://YOUR_VPS_IP:8088/

3. Добавить первый роутер на VPS

Пример:

sudo /opt/owrt-remote/owrt-remote-hub.py add-router \
  --id main \
  --name "Главный роутер" \
  --role main \
  --entry-port 18080 \
  --vps-host YOUR_VPS_IP

Сгенерировать Xray config для VPS:

sudo /opt/owrt-remote/owrt-remote-hub.py render-xray --out /etc/xray/owrt-remote.json

Создать systemd-сервис Xray reverse:

XRAY_BIN="$(command -v xray || command -v /usr/local/bin/xray || command -v /usr/bin/xray)"
sudo tee /etc/systemd/system/owrt-remote-xray.service >/dev/null <<EOF
[Unit]
Description=OpenWrt Remote Xray Reverse
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=$XRAY_BIN run -config /etc/xray/owrt-remote.json
Restart=on-failure
RestartSec=3

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now owrt-remote-xray

Открыть порты:

sudo ufw allow 8088/tcp
sudo ufw allow 8443/tcp

Проверить:

sudo ss -lntp | grep -E ':(8088|8443|18080)\b'

Порт 18080 должен слушать только 127.0.0.1. Наружу нужны 8088 для Hub и 8443 для Xray.

Установка на OpenWrt

Поставить агент:

wget -O - "https://raw.githubusercontent.com/kzolotarev95/luci-app-owrt-remote/main/install.sh?v=$(date +%s)" | sh

Открыть локальную панель:

LuCI -> Службы -> OpenWrt Remote

Или напрямую:

http://192.168.1.1/cgi-bin/owrt-remote

В VPS Hub открой карточку роутера -> OpenWrt config, вставь готовые UCI-команды в терминал роутера, потом:

owrt-remote render-client
/etc/init.d/owrt-remote enable
/etc/init.d/owrt-remote restart
owrt-remote doctor
owrt-remote heartbeat

Xray на OpenWrt

Если хватает flash-памяти:

opkg update
opkg install xray-core

Если flash мало, можно запустить Xray из RAM для теста:

mkdir -p /var/lock /var/run /tmp/owrt-xray
cd /tmp/owrt-xray
wget -O xray.zip "https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-arm64-v8a.zip"
command -v unzip >/dev/null 2>&1 || { opkg update; opkg install unzip; }
unzip -o xray.zip xray
chmod +x /tmp/owrt-xray/xray
/tmp/owrt-xray/xray version
uci set owrtremote.main.xray_bin='/tmp/owrt-xray/xray'
uci commit owrtremote
/etc/init.d/owrt-remote restart

Для другой архитектуры скачай подходящий архив Xray:

https://github.com/XTLS/Xray-core/releases/latest

Обновление

VPS

sudo wget -O /opt/owrt-remote/owrt-remote-hub.py "https://raw.githubusercontent.com/kzolotarev95/luci-app-owrt-remote/main/vps/owrt-remote-hub.py?v=$(date +%s)"
sudo wget -O /etc/systemd/system/owrt-remote.service "https://raw.githubusercontent.com/kzolotarev95/luci-app-owrt-remote/main/vps/owrt-remote.service?v=$(date +%s)"
sudo chmod +x /opt/owrt-remote/owrt-remote-hub.py
sudo systemctl daemon-reload
sudo systemctl restart owrt-remote
sudo /opt/owrt-remote/owrt-remote-hub.py render-xray --out /etc/xray/owrt-remote.json
sudo systemctl restart owrt-remote-xray

OpenWrt

wget -O - "https://raw.githubusercontent.com/kzolotarev95/luci-app-owrt-remote/main/install.sh?v=$(date +%s)" | sh
owrt-remote render-client
/etc/init.d/owrt-remote restart
owrt-remote heartbeat

Обновление строго по commit SHA

Так удобнее, если GitHub raw отдает старый кэш:

SHA="PUT_COMMIT_SHA_HERE"
export RAW_URL="https://raw.githubusercontent.com/kzolotarev95/luci-app-owrt-remote/$SHA"
wget -O - "$RAW_URL/install.sh" | sh

Команды VPS Hub

sudo /opt/owrt-remote/owrt-remote-hub.py init
sudo /opt/owrt-remote/owrt-remote-hub.py set-login --username admin --password admin
sudo /opt/owrt-remote/owrt-remote-hub.py add-router --id main --name "Главный роутер" --role main --entry-port 18080 --vps-host YOUR_VPS_IP
sudo /opt/owrt-remote/owrt-remote-hub.py list-routers
sudo /opt/owrt-remote/owrt-remote-hub.py render-xray --out /etc/xray/owrt-remote.json
sudo /opt/owrt-remote/owrt-remote-hub.py print-openwrt-config --id main --hub-url http://YOUR_VPS_IP:8088 --vps-host YOUR_VPS_IP

Команды OpenWrt агента

owrt-remote status
owrt-remote doctor
owrt-remote render-client
owrt-remote render-client --stdout
owrt-remote heartbeat

Диагностика

На роутере:

owrt-remote doctor
owrt-remote status
owrt-remote heartbeat

На VPS:

sudo systemctl status owrt-remote --no-pager -l
sudo systemctl status owrt-remote-xray --no-pager -l
sudo journalctl -u owrt-remote-xray -n 100 --no-pager
curl -v --max-time 10 http://127.0.0.1:18080/cgi-bin/luci

Если curl возвращает HTML LuCI или 403 Forbidden со страницей входа LuCI, туннель работает. Открывай Hub и нажимай Админка.

Что ставится на OpenWrt

Путь Назначение
/usr/sbin/owrt-remote CLI-агент: render config, heartbeat, status
/etc/init.d/owrt-remote procd-сервис: Xray reverse + heartbeat loop
/www/cgi-bin/owrt-remote локальная CGI-панель настройки
/www/luci-static/resources/view/owrt_remote.js LuCI redirect
/usr/share/luci/menu.d/luci-app-owrt-remote.json пункт меню LuCI
/usr/share/rpcd/acl.d/luci-app-owrt-remote.json LuCI ACL
/etc/config/owrtremote UCI-настройки
/etc/owrt-remote/web.key приватный ключ локальной панели

Безопасность

  • Не открывай LuCI роутера напрямую в интернет.
  • Entry-порты роутеров на VPS слушают только 127.0.0.1.
  • Hub защищен логином и паролем.
  • Heartbeat от роутеров защищен отдельным AGENT_TOKEN.
  • Для постоянного боевого режима лучше поставить Hub за HTTPS через Caddy или Nginx.
  • После первого входа admin/admin лучше сразу поменять пароль в блоке Доступ к Hub.