centos 關閉FireWall 和SELinux(包含圖文)
阿新 • • 發佈:2019-01-01
1. 環境
centos-7.x
選擇最完整版安裝(workstation選項)VMware Workstation 10.0.0
2. 關閉FireWall和SELinux
2.1 FireWall
使用systemctl status firewalld
檢視防火牆的狀態,如下(預設開啟)
[root@localhost ~]# systemctl status firewalld
// 防火牆狀態
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since 三 2018 -03-28 07:07:33 CST; 7h left
Docs: man:firewalld(1)
Main PID: 1055 (firewalld)
CGroup: /system.slice/firewalld.service
└─1055 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
.....
.....
如果你需要使用FireWall服務(正式環境下),則需要修改它的配置,因為在預設情況下,它會攔截大多數服務請求。具體可以參考配置firewalld服務的基本操作和設定。
如果由於某些原因(比如博主只是需要linux伺服器來搭建某些服務,不想控制防火牆只開放某些埠)等而不需要FireWall服務,則可以像下面那樣停止並禁用它。
// 關閉服務
[root@localhost ~]# systemctl stop firewalld
// 關閉開機自動開啟FireWall服務
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
2.2 關閉SELinux
可以用getenforce
[root@localhost ~]# getenforce
//開啟狀態
Enforcing
同上,如果你想使用SELinux也可以。但是博主不想那麼麻煩,所以把SELinux也關閉了。
[[email protected] ~]# vi /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.
// 這裡改變為disabled
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
// 重啟使配置生效
[[email protected] ~]# reboot
3. 錯誤集錦
- 切換成root使用者操作