在Debian系统中,可以通过配置iptables或firewalld来制定防火墙策略。以下是两种方法的详细说明:
sudo apt-get update
sudo apt-get install iptables
sudo nano /etc/iptables/rules.v4
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -p tcp --dport 22 -j ACCEPT
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
sudo iptables-restore < /etc/iptables/rules.v4
sudo cp /etc/iptables/rules.v4 /etc/network/if-up.d/iptables.rules
sudo chmod +x /etc/network/if-up.d/iptables.rules
sudo iptables -L
sudo apt-get update
sudo apt-get install firewalld
sudo systemctl start firewalld
sudo systemctl enable firewalld
sudo firewall-cmd --get-zones
sudo firewall-cmd --set-default-zone=public
sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp
sudo firewall-cmd --reload
sudo firewall-cmd --zone=public --list-ports
通过以上步骤,您可以根据需要制定Debian系统的防火墙策略。建议根据实际网络环境和安全需求调整规则,并定期审查和更新防火墙配置以确保安全性。