一、准备工作

1.1、服务器准备

操作系统:centos 7.x

1.2、安装好用的文本编辑工具nano

# yum -y install nano

二、关闭SELinux

2.1、查看SELinux状态

2.1.1、第一种:查看SELinux状态方法

# /usr/sbin/sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      31

2.1.2、第二种:查看SELinux状态方法

# getenforce
Enforcing

2.2、临时关闭SELinux

# setenforce 0

2.2.1、临时关闭后第一种方法查看SELinux状态

# /usr/sbin/sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive    //注意这里是 permissive
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      31

2.2.2、临时关闭后第二种方法查看SELinux状态

# getenforce
Permissive

2.2.3、临时关闭后可以再次打开SELinux

# setenforce 1

2.3、永久关闭SELinux

2.3.1、修改配置文件/etc/sysconfig/selinux

# nano /etc/sysconfig/selinux

selinux=enforcing 改为 selinux=disabled

# 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.
# ↓↓↓↓这里修改成disabled
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

2.3.2、重启后新配置生效

# reboot

2.3.3、临时关闭后第一种方法查看SELinux状态

# /usr/sbin/sestatus
SELinux status:                 disabled

2.3.4、临时关闭后第二种方法查看SELinux状态

# getenforce
Disabled

三、关闭防火墙firewall

3.1、查看防火墙状态

# systemctl status firewalld

防火墙开启状态下显示如下

● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
//这行是我添加的备注↓↓↓注意这里的 active (running)
   Active: active (running) since Wed 2020-01-01 17:05:47 CST; 9s ago
     Docs: man:firewalld(1)
 Main PID: 6787 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─6787 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

Jan 01 17:05:47 iZuf65lq1u9ra1ohnf5kebZ systemd[1]: Starting firewalld - dynamic firewall daemon...
Jan 01 17:05:47 iZuf65lq1u9ra1ohnf5kebZ systemd[1]: Started firewalld - dynamic firewall daemon.

3.2、关闭防火墙

# systemctl stop firewalld

3.3、关闭后查看状态

# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Jan 01 17:05:47 iZuf65lq1u9ra1ohnf5kebZ systemd[1]: Starting firewalld - dynamic firewall daemon...
Jan 01 17:05:47 iZuf65lq1u9ra1ohnf5kebZ systemd[1]: Started firewalld - dynamic firewall daemon.
Jan 01 17:11:58 iZuf65lq1u9ra1ohnf5kebZ systemd[1]: Stopping firewalld - dynamic firewall daemon...
Jan 01 17:11:58 iZuf65lq1u9ra1ohnf5kebZ systemd[1]: Stopped firewalld - dynamic firewall daemon.

3.4、关闭防火墙开机自启动

# systemctl disable firewalld.service

3.5、关闭防火墙开机自启动后查看防火墙状态

# 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)

Jan 01 17:05:47 iZuf65lq1u9ra1ohnf5kebZ systemd[1]: Starting firewalld - dynamic firewall daemon...
Jan 01 17:05:47 iZuf65lq1u9ra1ohnf5kebZ systemd[1]: Started firewalld - dynamic firewall daemon.
Jan 01 17:11:58 iZuf65lq1u9ra1ohnf5kebZ systemd[1]: Stopping firewalld - dynamic firewall daemon...
Jan 01 17:11:58 iZuf65lq1u9ra1ohnf5kebZ systemd[1]: Stopped firewalld - dynamic firewall daemon.

Eword 原创学习笔记
文档编号:E20200101-1
文档标签:Centos、防火墙、firewall、SELinux
转载请注明出处:http://www.eword.name

【E20200101-1】Centos 7.x 关闭防火墙(firewall)和SELinux的更多相关文章

  1. centOS 6.5关闭防火墙步骤

    centOS 6.5关闭防火墙步骤 关闭命令:  service iptables stop         永久关闭防火墙:chkconfig iptables off 两个命令同时运行,运行完成后 ...

  2. CentOS 7.2 关闭防火墙

    CentOS7 的防火墙配置跟以前版本有很大区别,CentOS7这个版本的防火墙默认使用的是firewall,与之前的版本使用iptables不一样 1.关闭防火墙: systemctl stop f ...

  3. CentOS开启和关闭防火墙

    CentOS Linux开启和关闭防火墙命令有两种,一种是临时的,重启即复原:另外一种是永久性的,重启不会复原.   1) 临时生效,重启后复原 开启: service iptables start ...

  4. centos 7.X关闭防火墙和selinux

    一.关闭防火墙 centos从7开始默认用的是firewalld,这个是基于iptables的,虽然有iptables的核心,但是iptables的服务是没安装的. 所以你只要停止firewalld服 ...

  5. Linux下Centos 7如何关闭防火墙?

    Linux下的防火墙有两种:Iptables和Firewall(概念以及区别大家可以自行搜索).为什么要关闭防火墙呢?主要是我们都过Linux搭建服务器的时候其他机器访问会被墙掉,例如:Tomcat, ...

  6. CentOS 6.5关闭防火墙

    关闭命令:  service iptables stop 永久关闭防火墙:chkconfig iptables off 两个命令同时运行,运行完成后查看防火墙关闭状态 service iptables ...

  7. centos 6.5 关闭防火墙

    关闭防火墙分为临时关闭和永久关闭.临时关闭重启系统后恢复正常,永久关闭重启系统后仍然是关闭状态 临时关闭与开启 service iptables stop service iptables start ...

  8. centos 8.3关闭防火墙,设置开机启动禁用防火墙

    关闭防火墙 [root@bogon ~]# systemctl stop firewalld      开机禁用防火墙 [root@bogon ~]# systemctl disable firewa ...

  9. CentOS 7.0关闭默认firewall防火墙启用iptables防火墙

    操作系统环境:CentOS Linux release 7.0.1406(Core) 64位CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤. 1.关闭f ...

随机推荐

  1. 如何不让EditText不获得焦点

    http://blog.csdn.net/get123/article/details/9004661

  2. 流程控制 Day06

    package com.sxt.arraytest2; public class breakTest { public static void main(String[] args) { label: ...

  3. 模板—Hash_map

    struct Hash_map { ],nx[]; ];]; inline double &operator [] (int x) { ,i=fi[k]; for(;i&&st ...

  4. Laravel的请求声明周期

    声明周期概述# 开始# public/index.php 文件是所有对Laravel应用程序的请求的入口点.而所有的请求都是经由你的Web服务器(Apache/Nginx) 通过配置引导到这个文件.i ...

  5. 13-4 jquery操作标签(文本,属性,class,value)

    一 文本操作 $().html() $().text() 文本赋值操作 $().html("") $().text("") 二 属性操作 $().attr(属性 ...

  6. 同一个C语言工程不同C文件之间的函数互相调用问题

    定义一个function.h文件来声明这些函数: //#ifndef __FUNCTION_H__//#define __FUNCTION_H__   int fun(int,int);   int ...

  7. python -- 类中--内置方法

    isinstance 和  issubclass isinstance(obj,b)  检查是否obj是否是类b的对象 class A(object):pass class B(A):pass b=B ...

  8. hdu 1430 魔板 (BFS+预处理)

    Problem - 1430 跟八数码相似的一题搜索题.做法可以是双向BFS或者预处理从"12345678"开始可以到达的所有状态,然后等价转换过去直接回溯路径即可. 代码如下: ...

  9. codeforces1249-div3

    A B C 等比数列的性质,前面的i项的和,不会超过第i+1项 D 有若干个区间,要求每一个点被区间覆盖的次数不能超过k个.问移除的最少的区间的数目. 贪心: 若某个点被覆盖了k次以上,那么肯定是移除 ...

  10. tp5 select出来数据集(对象)转成数组

    1.先在数据库配置文件中 //数据集返回类型 'resultset_type' => 'collection', 2.在使用时, 使用 toArray() 方法 //查询数据库 $news = ...