## 一、準備工作### 1.1、伺服器準備操作系統:centos 7.x### 1.2、安裝好用的文本編輯工具nano```linux# yum -y install nano```## 二、關閉SELinux### 2.1、查看SELinux狀態#### 2.1.1、第一種:查看SELinux狀... ...
一、準備工作
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