一、准备工作

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. ADO.NET_02

    一.说明 这个例子是小白跟着学习代码记录,模拟用户登陆功能,并可以查询所有学生信息. 二.代码 共4个文件,如下 App.config <?xml version="1.0" ...

  2. python 空值(NoneType)

  3. 阿里云IPv6 DDoS防御被工信部认定为“网络安全技术应用试点示范项目”

    ​​近日,阿里云数据中心骨干网IPv6 DDoS网络安全防御被工业和信息化部认定为“网络安全技术应用试点示范项目”,本次评选由工业和信息部网络安全管理局发起,从实用性.创新性.先进性.可推广性等维度展 ...

  4. golang gin框架 使用swagger生成api文档

    github地址:https://github.com/swaggo/gin-swagger 1.下载swag $ go get -u github.com/swaggo/swag/cmd/swag ...

  5. 像Google一样构建机器学习系统3 - 利用MPIJob运行ResNet101

    本系列将利用阿里云容器服务,帮助您上手Kubeflow Pipelines. 第一篇:在阿里云上搭建Kubeflow Pipelines 第二篇:开发你的机器学习工作流 第三篇:利用MPIJob运行R ...

  6. pytorch学习笔记(十二):详解 Module 类

    Module 是 pytorch 提供的一个基类,每次我们要 搭建 自己的神经网络的时候都要继承这个类,继承这个类会使得我们 搭建网络的过程变得异常简单. 本文主要关注 Module 类的内部是怎么样 ...

  7. ubuntu14.04 dnsmasq搭建本地名字服务器

    1 修改dnsmasq配置文件/etc/dnsmasq.conf 在/etc/dnsmasq.conf文件底部增加 #++++++++++++++++++++++++++++++++++++++++ ...

  8. .net core 控制台下使用HttpClientFactory封装

    HttpClientFactory封装,如有错误请指出,谢谢! using System; using System.Collections.Generic; using System.Net.Htt ...

  9. H3C 以太网集线器

  10. Java 对象序列化机制详解

    对象序列化的目标:将对象保存到磁盘中,或允许在网络中直接传输对象. 对象序列化机制允许把内存中的Java对象转换成平台无关的二进制流,从而允许把这种二进制流持久的保存在磁盘上,通过网络将这种二进制流传 ...