-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiagnose_network.sh
More file actions
executable file
·40 lines (34 loc) · 1.02 KB
/
diagnose_network.sh
File metadata and controls
executable file
·40 lines (34 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
echo "=== WatchRemote 网络诊断 ==="
echo ""
echo "1. 检查 Mac IP 地址:"
ifconfig | grep "inet " | grep -v "127.0.0.1"
echo ""
echo "2. 检查服务器是否运行:"
if lsof -i :12266 > /dev/null 2>&1; then
echo "✓ 服务器正在运行在端口 12266"
lsof -i :12266 | grep LISTEN
else
echo "✗ 服务器未运行"
fi
echo ""
echo "3. 测试服务器响应:"
for ip in $(ifconfig | grep "inet " | grep -v "127.0.0.1" | awk '{print $2}'); do
echo " 测试 $ip:12266..."
response=$(curl -s -m 2 http://$ip:12266/ping 2>&1)
if [ "$response" = "pong" ]; then
echo " ✓ $ip 响应正常"
else
echo " ✗ $ip 无响应"
fi
done
echo ""
echo "4. 检查防火墙状态:"
firewall_status=$(/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate)
echo " $firewall_status"
echo ""
echo "5. 建议:"
echo " - 确保 Apple Watch 已连接到 Wi-Fi"
echo " - 确保 Watch 和 Mac 在同一个网络"
echo " - 在 Watch App 中使用上面显示的 IP 地址"
echo ""