MikeWang000000 / Natter

Expose your TCP/UDP port behind full-cone NAT to the Internet.
GNU General Public License v3.0
1.31k stars 107 forks source link

Nginx-Cloudflare示例运行失败 #67

Closed despire1119 closed 3 months ago

despire1119 commented 3 months ago

大佬对不起又是我,我尝试部署Nginx-Cloudflare报:Network natteriso_default Error . cf-redir.py配置:

cf_redirect_to_https    = False^M
cf_redirect_host        = "xxxxxxx.fun"^M
cf_direct_host          = "ip:port"^M
cf_auth_email           = "xxxxxxx@hotmail.com"^M
cf_auth_key             = "*******************"^M

运行报错:

✘ Network natteriso_default  Error                                                                                                                                                                  0.0s 
failed to create network natteriso_default: Error response from daemon: Failed to program FILTER chain: iptables failed: iptables --wait -I FORWARD -o br-882ab910cf0f -j DOCKER: iptables v1.8.4 (legacy): Couldn't load target `DOCKER':No such file or directory

烦请帮忙看看是否又是iptables问题?感谢!

MikeWang000000 commented 3 months ago

这个和 Natter 关系不大,看起来是 Docker 或者是操作系统的问题。

首先先测试下您的 Docker 是否能正常创建网络:

docker network create test_net
docker network rm test_net

如果上面命令失败了,先排查 Docker 出现的故障吧。


另外为了方便定位问题,麻烦提供下相关版本号:

uname -a
cat /etc/os-release
iptables --version
docker version
despire1119 commented 3 months ago

确实是我的系统问题,以下是我可以查到的信息:

  1. 系统版本: Linux AS6704T-5FDB 5.13.x #1 SMP Wed Mar 13 00:11:10 CST 2024 x86_64 GNU/Linux

  2. iptables version:

    iptables v1.8.4 (legacy)
  3. 运行docker network create test_net

    
    Error response from daemon: Failed to program FILTER chain: iptables failed: iptables --wait -I FORWARD -o br-3e42f43f0721 -j DOCKER: iptables v1.8.4 (legacy): Couldn't load target `DOCKER':No such file or directory

Try iptables -h' or 'iptables --help' for more information. (exit status 2) root@AS6704T-5FDB:/volume1/natterISO # docker network create test_net Error response from daemon: Failed to program FILTER chain: iptables failed: iptables --wait -I FORWARD -o br-0a438d66b352 -j DOCKER: iptables v1.8.4 (legacy): Couldn't load targetDOCKER':No such file or directory

Try `iptables -h' or 'iptables --help' for more information. (exit status 2)

4. docker版本:

Client: Version: 25.0.3 API version: 1.44 Go version: go1.21.6 Git commit: 4debf41 Built: Tue Feb 6 21:13:00 2024 OS/Arch: linux/amd64 Context: default

Server: Docker Engine - Community Engine: Version: 25.0.3 API version: 1.44 (minimum version 1.24) Go version: go1.21.6 Git commit: f417435 Built: Tue Feb 6 21:13:08 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: v1.7.13 GitCommit: 7c3aca7a610df76212171d200ca3811ff6096eb8 runc: Version: 1.1.12 GitCommit: v1.1.12-0-g51d5e94 docker-init: Version: 0.19.0 GitCommit: de40ad0

MikeWang000000 commented 3 months ago

不知道什么原因,你的系统缺少了 Docker 相关的 chain。 如果是 NAS 专用操作系统,可以向有关厂商提单。

不过,可以尝试通过下面的方式手动补回来。

iptables -t filter -N DOCKER
iptables -t filter -N DOCKER-ISOLATION-STAGE-1
iptables -t filter -N DOCKER-ISOLATION-STAGE-2
iptables -t filter -N DOCKER-USER
iptables -t nat -N DOCKER

另外,也可以规避创建网络,就是在 docker-compose.yml 里加上 network_mode: bridge

despire1119 commented 3 months ago

感谢回复,按照大佬的方法尝试手补,提示nat已存在,于是又运行了一次docker compose up,成功了(虽然不知道咋回事)。

但在成功运行的log中有一行/usr/bin/env: ‘python3\r’: No such file or directory,服务端口可以正常访问,不知这个抛出有何影响?

[+] Running 2/0
 ✔ Container natteriso-nginx-1            Created                                                                               0.0s 
 ✔ Container natteriso-natter-nginx-cf-1  Created                                                                               0.0s 
Attaching to natter-nginx-cf-1, nginx-1
nginx-1            | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx-1            | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx-1            | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx-1            | 10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled
nginx-1            | /docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
nginx-1            | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx-1            | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
nginx-1            | /docker-entrypoint.sh: Configuration complete; ready for start up
nginx-1            | 2024/03/21 13:18:43 [notice] 1#1: using the "epoll" event method
nginx-1            | 2024/03/21 13:18:43 [notice] 1#1: nginx/1.25.4
nginx-1            | 2024/03/21 13:18:43 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14) 
nginx-1            | 2024/03/21 13:18:43 [notice] 1#1: OS: Linux 5.13.x
nginx-1            | 2024/03/21 13:18:43 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1024:4096
nginx-1            | 2024/03/21 13:18:43 [notice] 1#1: start worker processes
nginx-1            | 2024/03/21 13:18:43 [notice] 1#1: start worker process 21
nginx-1            | 2024/03/21 13:18:43 [notice] 1#1: start worker process 22
nginx-1            | 2024/03/21 13:18:43 [notice] 1#1: start worker process 23
nginx-1            | 2024/03/21 13:18:43 [notice] 1#1: start worker process 24
natter-nginx-cf-1  | 2024-03-21 13:18:44 [I] Natter v2.0.0-rc3
natter-nginx-cf-1  | 2024-03-21 13:18:49 [I] 
natter-nginx-cf-1  | 2024-03-21 13:18:49 [I] tcp://192.168.1.107:2335 <--socket--> tcp://192.168.1.107:44463 <--Natter--> tcp://-:-
natter-nginx-cf-1  | 2024-03-21 13:18:49 [I] 
natter-nginx-cf-1  | 2024-03-21 13:18:49 [I] Calling script: /opt/cf-redir.py
natter-nginx-cf-1  | /usr/bin/env: ‘python3\r’: No such file or directory
natter-nginx-cf-1  | /usr/bin/env: use -[v]S to pass options in shebang lines
natter-nginx-cf-1  | 2024-03-21 13:18:49 [I] LAN > -    [ OPEN ]
natter-nginx-cf-1  | 2024-03-21 13:18:49 [I] LAN > -   [ OPEN ]
natter-nginx-cf-1  | 2024-03-21 13:18:49 [I] LAN > -   [ OPEN ]
natter-nginx-cf-1  | 2024-03-21 13:18:51 [I] WAN > -   [ OPEN ]
natter-nginx-cf-1  | 2024-03-21 13:18:51 [I] 

感谢

MikeWang000000 commented 3 months ago

原因是:你使用的是Windows的记事本编辑的脚本文件。 换行符格式与Linux不兼容。

请删除这个脚本,使用专用代码编辑器例如:VSCode, Notepad3 等,根据原文件重新修改。

despire1119 commented 3 months ago

Sorry, 我自罚一杯,感谢回复。