#!/bin/bash # 502/530 但隧道连着 —— 查回源配置(这是我唯一还没验证过的一环) set -u BASE=http://127.0.0.1:8080 echo "════════ 1. 隧道 ingress 配置全文 ════════" cat /root/.cloudflared/config.yml 2>/dev/null | sed 's/^/ /' echo echo "════════ 2. relay 到底监听哪个地址 ════════" ss -lntp 2>/dev/null | grep 8080 | sed 's/^/ /' echo " ---" printf " 127.0.0.1:8080 -> HTTP %s\n" "$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 http://127.0.0.1:8080/v1/health)" printf " localhost:8080 -> HTTP %s\n" "$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 http://localhost:8080/v1/health)" printf " 192.168.10.105:8080 -> HTTP %s\n" "$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 http://192.168.10.105:8080/v1/health)" echo echo "════════ 3. cloudflared 能看到 relay 吗(同一台机器)════════" echo " cloudflared 进程:" pgrep -af 'cloudflared tunnel' | head -2 | sed 's/^/ /' echo echo "════════ 4. 隧道 metrics 全量 ════════" curl -s --max-time 5 http://127.0.0.1:20241/metrics 2>/dev/null \ | grep -E '^cloudflared_tunnel' | sed 's/^/ /' echo echo "════════ 5. 最近的注册/掉线(看 4 条是不是刚连上的)════════" tail -300 /root/lanremote-relay/tunnel.log 2>/dev/null \ | grep -E 'Registered|Lost|Retrying|i/o timeout|error' \ | tail -20 | sed 's/^/ /' echo echo "════════ 6. 公网连打 15 次(看是持续挂还是间歇)════════" ok=0 for i in $(seq 1 15); do c=$(curl -s -o /dev/null -w '%{http_code}' --max-time 15 \ -H 'User-Agent: LanRemote/1.4.0' https://relay.xxmxxs.top/v1/health) [ "$c" = "200" ] && ok=$((ok+1)) printf " %2d: %s\n" "$i" "$c" sleep 1 done echo " 可用 $ok/15" echo echo "════════ 7. 每次请求是不是落到不同机房 ════════" for i in 1 2 3 4 5 6; do ray=$(curl -sI --max-time 12 -H 'User-Agent: LanRemote/1.4.0' \ https://relay.xxmxxs.top/v1/health 2>/dev/null \ | grep -i '^cf-ray' | tr -d '\r' | awk '{print $2}') code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 12 \ -H 'User-Agent: LanRemote/1.4.0' https://relay.xxmxxs.top/v1/health) printf " HTTP %s cf-ray %s\n" "$code" "$ray" done echo echo "════════ 8. DNS 解析到哪 ════════" getent ahostsv4 relay.xxmxxs.top 2>/dev/null | awk '{print $1}' | sort -u | sed 's/^/ v4: /' getent ahostsv6 relay.xxmxxs.top 2>/dev/null | awk '{print $1}' | sort -u | head -3 | sed 's/^/ v6: /'