当我使用 iptables 通过以下任一方式阻止传入流量时:
- iptables -A INPUT -j REJECT
或者
- iptables -P INPUT DROP
它超时了,什么也没说,只是完成拉动。(需要 1 分钟)。
我当前的配置:
*filter
:INPUT ACCEPT [29875:3958669]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [263459:37321297]
:DOCKER - [0:0]
:DOCKER-ISOLATION-STAGE-1 - [0:0]
:DOCKER-ISOLATION-STAGE-2 - [0:0]
:DOCKER-USER - [0:0]
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 20 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8443 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 2022 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -j DOCKER-USER
-A FORWARD -j DOCKER-ISOLATION-STAGE-1
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o docker0 -j DOCKER
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A FORWARD -o pterodactyl0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o pterodactyl0 -j DOCKER
-A FORWARD -i pterodactyl0 ! -o pterodactyl0 -j ACCEPT
-A FORWARD -i pterodactyl0 -o pterodactyl0 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A DOCKER-ISOLATION-STAGE-1 -i docker0 ! -o docker0 -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -i pterodactyl0 ! -o pterodactyl0 -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -j RETURN
-A DOCKER-ISOLATION-STAGE-2 -o docker0 -j DROP
-A DOCKER-ISOLATION-STAGE-2 -o pterodactyl0 -j DROP
-A DOCKER-ISOLATION-STAGE-2 -j RETURN
-A DOCKER-USER -j RETURN
COMMIT
*nat
:PREROUTING ACCEPT [1352:194638]
:INPUT ACCEPT [891:120286]
:OUTPUT ACCEPT [1048:62993]
:POSTROUTING ACCEPT [1048:62993]
:DOCKER - [0:0]
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
-A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE
-A POSTROUTING -s 172.18.0.0/16 ! -o pterodactyl0 -j MASQUERADE
-A DOCKER -i docker0 -j RETURN
-A DOCKER -i pterodactyl0 -j RETURN
COMMIT
当我将策略保留为接受或不拒绝不需要的流量时,docker 的工作速度显着加快,并且似乎不会超时:
[Pterodactyl Daemon]: Pulling Docker container image, this could take a few minutes to complete...
---this information doesn't show up when I have closed ports---
Pulling from pterodactyl/yolks
Status: Image is up to date for ghcr.io/pterodactyl/yolks:java_17
Digest: sha256:2dc464502b22a0c64edbc10a347d9f72b4581640be487b5eb750785d26ccad04
---this information doesn't show up when I have closed ports---
[Pterodactyl Daemon]: Finished pulling Docker container image
那么我做错了什么或者有什么需要改进的地方吗?(我是新手,我以前使用过firewalld,它工作得很好,但不能满足我的需求)。
我很愚蠢,这很简单:
对于已经建立的连接来说,要达到低谷。