Debian 防火墙可以保护多种服务,主要通过配置管理防火墙的软件来实现,如 iptables
和 ufw
。以下是 Debian 防火墙能够保护的一些服务和相关配置方法:
Debian 防火墙保护的服务
- Web 服务器:如 Apache、Nginx 等,默认通过端口 80(HTTP)和 443(HTTPS)提供服务。
- 邮件服务器:如 Postfix、Exim 等,通常通过端口 25(SMTP)、143(IMAP)、110(POP3)等提供服务。
- 数据库服务器:如 MySQL、PostgreSQL 等,通常通过端口 3306(MySQL)、5432(PostgreSQL)等提供服务。
- SSH 服务:通过端口 22 提供安全的 shell 访问。
- 其他服务:根据具体安装的软件,可能还包括 DNS(端口 53)、FTP(端口 20 和 21)等。
配置 Debian 防火墙的方法
-
使用 ufw:
- 安装 ufw:
sudo apt update && sudo apt install ufw
- 允许 SSH 连接:
sudo ufw allow ssh
- 允许 HTTP 服务:
sudo ufw allow http
- 启用 ufw:
sudo ufw enable
- 安装 ufw:
-
使用 iptables:
- 安装 iptables:
sudo apt get update && sudo apt get install iptables
- 允许 SSH 连接:
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
- 拒绝 HTTP 服务:
sudo iptables -A INPUT -p tcp --dport 80 -j DROP
- 保存 iptables 规则:
sudo iptables-save /etc/iptables/rules.v4
- 加载 iptables 规则:
sudo iptables-restore /etc/iptables/rules.v4
- 安装 iptables:
通过上述配置,可以有效地保护 Debian 系统上的关键服务,防止未经授权的访问。