centos 7 和 centos 6 防火墙 别再傻傻分不清了

centos6:

配置文件:

/etc/sysconfig/iptables

相关命令:

/etc/init.d/iptables  start/stop/restart/status    


centos7防火墙默认没有安装iptables,默认使用的是firewall作为防火墙

相关命令:

1.firewall-cmd --state         查看默认防火墙状态

2.启动一个服务:systemctl start firewalld.service

3.关闭一个服务:systemctl stop firewalld.service

4.重启一个服务:systemctl restart firewalld.service

5.查看已经开放的端口: firewall-cmd --list-ports

6.开启端口:firewall-cmd --zone=public --add-port=80/tcp --permanent

–zone #作用域

–add-port=80/tcp #添加端口,格式为:端口/通讯协议

–permanent #永久生效,没有此参数重启后失效


centos7 中安装iptables服务:

1、直接关闭防火墙

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

2、设置 iptables service

yum -y install  iptables-services

添加防火墙条件:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

3.iptables服务的命令:

systemctl start iptables.service #打开防火墙

systemctl stop iptables.service #关闭防火墙

systemctl enable iptables.service  #设置防火墙开机启动

systemctl restart iptables.service    #重启防火墙使配置生效

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容