Centos6、Centos7、Centos8关闭防火墙

一、centos6关闭防火墙

1.service命令

关闭防火墙:service iptables stop

开启防火墙:service iptables start

重启防火墙:service iptables restart

查看防火墙状态:service iptables status

2.通过:/etc/init.d/iptables 进行操作

关闭防火墙:/etc/init.d/iptables stop(这是临时关闭,关闭的是当前运行的防火墙,重启之后防火墙又会启动,因为它是开机自启动的,它相当于/etc/init.d/iptables start)

查看防火墙状态:/etc/init.d/iptables/status

3.需要改为开机不启动,使用chkconfig命令

永久关闭防火墙: chkconfig iptables off

永久开启防火墙: chkconfig iptables on

查看状态:chkconfig --list iptables

二、CentOS7防火墙默认使用的是firewall,与之前使用iptables不一样。

1、关闭防火墙

命令:systemctl stop firewalld.service

2、开启防火墙

命令:systemctl start firewalld.servicee

3、关闭开机启动防火墙

命令:systemctl disable firewalld.service

4、开机启动防火墙

命令:systemctl enable firewalld.service

5、常用端口放行

放行8080端口

放行8080端口

firewall-cmd --zone=public --add-port=8080/tcp --permanent

重启防火墙

firewall-cmd --reload

  • -zone ,作用域

  • -add-port=8080/tcp ,添加端口,格式为:端口/通讯协议

  • -permanent,永久生效,没有此参数,重启后失效

三、Centos8关闭防火墙

ystemctl status firewalld.service(查看防火墙状态)

active表示当前防火墙处于开启状态 inactive表示关闭状态

systemctl stop firewalld.service (关闭防火墙)

systemctl start firewalld.service (开启防火墙)

systemctl disable firewalld.service (禁止防火墙自启动)

systemctl enable firewalld.service (防火墙随系统开启启动)

原文链接:https://blog.csdn.net/the_shy369/article/details/127036896

posted @   哩个啷个波  阅读(1014)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示