Linux SELinux and iptables

本文介绍如何在CentOS系统中禁用SELinux和防火墙。通过修改配置文件或使用命令行,可以将SELinux设置为disabled状态,实现永久关闭。同时,利用systemctl命令可以临时或永久关闭防火墙,确保服务器的开放性和可访问性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.關閉SELinux功能

第一種修改配置文件,永久生效:
[root@VM_0_7_centos ~]# cat /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=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


[root@VM_0_7_centos ~]# 
第二種臨時關閉,setenforce 0相當於disabled,1 相當於enforcing。
[root@VM_0_7_centos ~]# setenforce 0
[root@VM_0_7_centos ~]# getenforce 
Disabled

2.關閉防火墻 for CentOS 7

查看防火墻狀態,關閉,開啟
[root@VM_0_7_centos ~]# systemctl status firewalld
● 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)
[root@VM_0_7_centos ~]# systemctl stop firewalld
[root@VM_0_7_centos ~]# systemctl start firewalld
[root@VM_0_7_centos ~]#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值