Linux系统关闭防火墙、selinux方法

互联网 2021/9/15 7:08:08

1、防火墙服务关闭 systemctl stop firewalld systemctl disable firewalld1.1 查看防火墙状态 systemctl status firewalld[root@server ~]# systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/…

1、防火墙服务关闭

systemctl stop firewalld
systemctl disable firewalld

1.1 查看防火墙状态

systemctl status firewalld
[root@server ~]# systemctl status firewalld.service 
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: active (running) since Mon 2020-12-14 15:24:39 CST; 4s ago
     Docs: man:firewalld(1)
 Main PID: 1625 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─1625 /usr/bin/python -Es /usr/sbin/firewalld --nofork -...

Dec 14 15:24:38 server.study.vv systemd[1]: Starting firewalld - dyn...
Dec 14 15:24:39 server.study.vv systemd[1]: Started firewalld - dyna...
Hint: Some lines were ellipsized, use -l to show in full.

1.2 临时关闭防火墙服务

systemctl stop firewalld
systemctl status firewalld    --- 操作完成确认
[root@server ~]# systemctl stop firewalld.service 
[root@server ~]# systemctl status firewalld.service 
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Dec 14 15:24:38 server.study.vv systemd[1]: Starting firewalld - dyn...
Dec 14 15:24:39 server.study.vv systemd[1]: Started firewalld - dyna...
Dec 14 15:26:43 server.study.vv systemd[1]: Stopping firewalld - dyn...
Dec 14 15:26:43 server.study.vv systemd[1]: Stopped firewalld - dyna...
Hint: Some lines were ellipsized, use -l to show in full.

1.3 永久关闭防火墙服务

systemctl disable firewalld

1.4 查看服务状态信息简便方法

systemctl is-active firewalld    --- 检查服务是否正常运行

[root@server ~]# systemctl is-active firewalld.service 
unknown

systemctl is-enabled firewalld    --- 检查确认服务是否开机运行
[root@server ~]# systemctl is-enabled firewalld.service 
disabled

2、selinux服务关闭

setenforce 0
sed -i.bak s/'^SELINUX=enforcing$'/'SELINUX=disabled'/g /etc/selinux/config

2.1 查看selinux服务状态

getenforce    --- 确认selinux服务是否开启或是关闭
[root@server ~]# getenforce 
Enforcing

2.2 临时关闭selinux服务

setenforce [1|0]    --- 1表示临时开启Enforcing,0表示临时关闭Permissive
getenforce    --- 关闭后确认
[root@server ~]# setenforce 0
[root@server ~]# getenforce 
Permissive

2.3 永久关闭selinux服务

修改/etc/selinux/config文件

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.    --- 服务处于正常开启状态
#     permissive - SELinux prints warnings instead of enforcing.    --- 服务被临时关闭了
#     disabled - No SELinux policy is loaded.    --- 服务被永久关闭
SELINUX=enforcing

第一步:修改配置文件

[root@server ~]# vi /etc/selinux/config 
SELINUX=disabled

第二步:系统重启生效配置

[root@server ~]# reboot

第三步:确认服务状态

[root@server ~]# getenforce 
Disabled
随时随地学软件编程-关注百度小程序和微信小程序
关于找一找教程网

本站文章仅代表作者观点,不代表本站立场,所有文章非营利性免费分享。
本站提供了软件编程、网站开发技术、服务器运维、人工智能等等IT技术文章,希望广大程序员努力学习,让我们用科技改变世界。
[Linux系统关闭防火墙、selinux方法]http://www.zyiz.net/tech/detail-228405.html

上一篇:Linux是什么

下一篇:linux学习分享(第十周)

赞(0)
关注微信小程序
程序员编程王-随时随地学编程

扫描二维码或查找【程序员编程王】

可以随时随地学编程啦!

技术文章导航 更多>
扫一扫关注最新编程教程