iptables firewalld

摘自http://vbird.dic.ksu.edu.tw/linux_server/0250simple_firewall_3.php#netfilter_iptables

linux 7

获得root 控制权限。在“#”下操作。

查看防火墙状态。 
systemctl status firewalld

临时关闭防火墙命令。重启电脑后,防火墙自动起来。 
systemctl stop firewalld

永久关闭防火墙命令。重启后,防火墙不会自动启动。 
systemctl disable firewalld

加入一条规则。

iptables -I INPUT -s 189.90.100.0/24  -p TCP --dport 8080  -j ACCEPT

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
iptablesfirewalld 都是 Linux 系统中的防火墙软件,它们的主要区别如下: 1. 配置文件位置不同:iptables 的配置文件在 /etc/sysconfig/iptables 中,而 firewalld 的配置文件在 /usr/lib/firewalld/ 和 /etc/firewalld/ 中的各种 XML 文件中。 2. 配置方式不同:iptables 仅能通过命令行进行配置,而 firewalld 提供了图形接口,类似于 Windows 防火墙的操作方式。 3. 工作原理不同:iptables 是基于内核的防火墙,它通过在内核中设置规则来过滤网络流量;而 firewalld 是基于用户空间的防火墙,它使用 D-Bus 与内核通信,并通过内核中的 netfilter 过滤网络流量。 下面是一个使用 iptables 配置防火墙的例子: ```shell # 清空所有规则 iptables -F # 设置默认策略 iptables -P INPUT DROP iptables -P FORWARD DROP iptables -P OUTPUT ACCEPT # 允许回环接口 iptables -A INPUT -i lo -j ACCEPT # 允许已建立的连接 iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # 允许 SSH 连接 iptables -A INPUT -p tcp --dport 22 -j ACCEPT # 允许 HTTP 和 HTTPS 连接 iptables -A INPUT -p tcp --dport 80 -j ACCEPT iptables -A INPUT -p tcp --dport 443 -j ACCEPT # 其他规则 iptables -A INPUT -j DROP ``` 下面是一个使用 firewalld 配置防火墙的例子: ```shell # 启动 firewalld systemctl start firewalld # 查看状态 systemctl status firewalld # 开启 SSH 连接 firewall-cmd --zone=public --add-service=ssh --permanent # 开启 HTTP 和 HTTPS 连接 firewall-cmd --zone=public --add-service=http --permanent firewall-cmd --zone=public --add-service=https --permanent # 其他规则 firewall-cmd --zone=public --remove-port=8080/tcp --permanent # 重新加载配置 firewall-cmd --reload ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值