«

Linux防火墙

时间:2023-3-14 20:21     作者:wen     分类: Linux


防火墙(Firewall)是一种网络安全系统,用于控制网络通信流量。防火墙通常位于网络边缘,用于保护受保护网络不受来自外部网络的攻击。以下是 Linux 系统下常见的防火墙软件及其使用方法:

  1. iptables - Linux 系统默认的防火墙软件,基于 netfilter 内核模块实现。示例命令:
    • 允许某个 IP 地址的所有流量通过:iptables -A INPUT -s ip-address -j ACCEPT
    • 允许某个端口的流量通过:iptables -A INPUT -p tcp --dport port-number -j ACCEPT
    • 禁止某个 IP 地址的所有流量通过:iptables -A INPUT -s ip-address -j DROP
    • 显示防火墙规则:iptables -L
  2. firewalld - CentOS/RHEL 7 以上版本默认的防火墙软件,基于 nftables 内核模块实现。示例命令:
    • 允许某个服务的流量通过:firewall-cmd --permanent --add-service service-name
    • 允许某个端口的流量通过:firewall-cmd --permanent --add-port port-number/tcp
    • 禁止某个服务的流量通过:firewall-cmd --permanent --remove-service service-name
    • 显示防火墙规则:firewall-cmd --list-all

以上是一些常见的 Linux 系统下的防火墙软件及其使用方法,可以根据实际情况选择和使用。需要注意的是,防火墙配置不当可能会影响到网络的正常通信,建议在配置防火墙前备份重要的数据和配置文件。

标签: linux