我正在尝试设置一些规则来阻止 TCP(SSH 和 FTP)上除 21 和 22 之外的所有端口。但是当我尝试运行这个脚本时,我被锁定在我的实例之外并且无法访问它。这是脚本:
# Flush the FW Rules
iptables -F
iptables -X
# Block all traffic
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
# Allow SSH
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 22 -j ACCEPT
# Allow FTP
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 21 -j ACCEPT
# Allow ICMP (ping)
iptables …
Run Code Online (Sandbox Code Playgroud)