首页 > 系统相关 >CentOS7/6 关闭防火墙(转载)

CentOS7/6 关闭防火墙(转载)

时间:2022-10-27 09:24:06浏览次数:36  
标签:service -- cmd 防火墙 firewalld CentOS7 firewall systemctl 转载

CentOS6关闭防火墙使用以下命令,

//临时关闭
service iptables stop
//禁止开机启动
chkconfig iptables off

CentOS7中若使用同样的命令会报错,

stop  iptables.service
Failed to stop iptables.service: Unit iptables.service not loaded.

这是因为CentOS7版本后防火墙默认使用firewalld,因此在CentOS7中关闭防火墙使用以下命令,

//临时关闭
systemctl stop firewalld
//禁止开机启动
systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

 1、firewalld的基本使用

启动: systemctl start firewalld 关闭: systemctl stop firewalld 查看状态: systemctl status firewalld  开机禁用  : systemctl disable firewalld 开机启用  : systemctl enable firewalld     2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。

启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed

3.配置firewalld-cmd

查看版本: firewall-cmd --version 查看帮助: firewall-cmd --help 显示状态: firewall-cmd --state 查看所有打开的端口: firewall-cmd --zone=public --list-ports 更新防火墙规则: firewall-cmd --reload 查看区域信息:  firewall-cmd --get-active-zones 查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0 拒绝所有包:firewall-cmd --panic-on 取消拒绝状态: firewall-cmd --panic-off 查看是否拒绝: firewall-cmd --query-panic   那怎么开启一个端口呢 添加 firewall-cmd --zone=public --add-port=80/tcp --permanent    (--permanent永久生效,没有此参数重启后失效) 重新载入 firewall-cmd --reload 查看 firewall-cmd --zone= public --query-port=80/tcp 删除 firewall-cmd  --remove-port=80/tcp --permanent --------------------------------------------------------------------------- centos6关闭防火墙: 先进入init.d目录,命令如下:
[root@centos6 ~]# cd /etc/init.d/

[root@centos6 init.d]#

然后
查看防火墙状态:
[root@centos6 init.d]# /etc/init.d/iptables status

暂时关闭防火墙:
[root@centos6 init.d]# /etc/init.d/iptables stop

重启iptables:
[root@centos6 init.d]# /etc/init.d/iptables restart   centos6 开启端口: 写入修改         /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT    保存修改           /etc/init.d/iptables save     重启防火墙,修改生效         service iptables restart    

标签:service,--,cmd,防火墙,firewalld,CentOS7,firewall,systemctl,转载
From: https://www.cnblogs.com/QIzhu/p/16830939.html

相关文章