Centos7 防火墙 firewalld

centos 7  弃用了iptables 采用 firewalld 服务为防火墙 firewall-cmd 命令


查看firewall 状态 的几种方式
[root@VM_0_13_centos html]# systemctl status firewalld //运行状态
[root@VM_0_13_centos html]# systemctl is-enabled firewalld //是否开机启动
[root@VM_0_13_centos html]# firewall-cmd --state  //是否运行


启用firewalld服务(防火墙)
[root@VM_0_13_centos html]# systemctl start firewalld
[root@VM_0_13_centos html]# systemctl stop firewalld
[root@VM_0_13_centos html]# systemctl restart firewalld


开机启动
[root@VM_0_13_centos html]# systemctl enable firewalld
[root@VM_0_13_centos html]# systemctl disable firewalld


查看已经启动的服务
[root@VM_0_13_centos html]# systemctl list-unit-files|grep enabled


设置防火墙
//查看已经开放的端口
root@VM_0_13_centos html]# firewall-cmd --list-ports
添加80端口
[root@VM_0_13_centos html]# firewall-cmd --zone=public --add-port=80/tcp --permanent
删除80端口
[root@VM_0_13_centos html]# firewall-cmd --zone=public --remove-port=80/tcp --permanent


–zone #作用域
–add-port=80/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效


重启 firewalld
[root@VM_0_13_centos html]# firewall-cmd --reload
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值