给 Unraid 开启 ip6tables 后,发现 Unraid Connect 报错 Unraid API Error, Cloud: socket closed 并且无法备份配置文件了。
2024-06-10 update:
问题解决了,应该是我防火墙没加 ESTABLISHED,RELATED
规则(
ip6tables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
推测是防火墙的问题,于是一番查询后发现 Unraid Connect 是由 unraid-api
这个二进制提供的。那就来看看它用的是哪个端口好啦。
lsof -i -P -n | grep unraid-ap
unraid-ap 5448 root 19u IPv4 21972 0t0 UDP 192.168.1.100:54435
unraid-ap 5448 root 20u IPv6 21973 0t0 UDP [2001:xxxx]:51423
unraid-ap 5448 root 21u IPv6 21974 0t0 UDP [2001:xxxx]:36283
unraid-ap 5448 root 25u IPv6 56784 0t0 TCP [2001:xxxx]:35856->[2606:xxxx]:443 (SYN_SENT)
猜测一下应该是 IPv6 的 35856
端口,那我们用 ip6tables -A INPUT -p tcp --dport 35856 -j ACCEPT
打开这个端口试试。刷新一下控制台发现问题解决了。但这个端口似乎是每次启动后会变的,那就比较麻烦了。
既然 IPv6 是白名单模式,且之前仅启用 IPv4 的时候没有问题。那么是不是我让 unraid-api
用 IPv4 就行了呢?
方法也很简单,User Scripts 里创建一个脚本,内容如下。
这样 unraid-api 就会优先使用 IPv4 连接了。(虽然我还是不知道为什么 IPv4 就没有问题)。
#!/bin/bash
cat>/etc/gai.conf<<EOF
label ::1/128 0
label ::/0 1
label 2002::/16 2
label ::/96 3
label ::ffff:0:0/96 4
precedence ::1/128 50
precedence ::/0 40
precedence 2002::/16 30
precedence ::/96 20
precedence ::ffff:0:0/96 10
EOF
sleep 5
unraid-api restart
或者也许把 mothership.unraid.net
的 IP 放行了也可以解决这个问题?
嘛总是能跑了就行了。(其实论坛里查了一圈,发现大家都只会重置 network.cfg 或者 unraid-api restart,难道你们都不用防火墙的么?)
另外虽然 unraid-api -h
里有个 -p
选项,但似乎并没有用
unraid-api -h
Unraid API
Thanks for using the official Unraid API
Usage:
$ unraid-api command <options>
Options:
-h, --help Prints this usage guide.
-d, --debug Enabled debug mode.
-p, --port string Set the graphql port.
--environment production/staging/development Set the working environment.
--log-level trace/debug/info/warn/error/fatal Set the log level.
Copyright © 2024 Lime Technology, Inc.
参考资料(其实主要的就是之前写 Transmission 那次的资料)
Setting IPv4 as preferred protocol over IPv6
https://forums.unraid.net/topic/136219-unraid-api-error-cloud-client-closed-connection/
https://forums.unraid.net/topic/141156-unraid-api-error-cloud-socket-closed/