# vim /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
將SELINUX=enforcing修改為SELINUX=disabled。
重啟linux系統(tǒng),然后使用getenforce命令查看當(dāng)前的SELINUX狀態(tài):
# getenforce Disabled
我使用的Linux發(fā)行版是CentOS,CentOS 7的默認(rèn)防火墻工具是firewalld,Cent OS6的默認(rèn)防火墻工具是iptables。
首先,需要知道當(dāng)前系統(tǒng)安裝的防火墻工具的是firewalld,還是iptableslinux常用命令linux常用命令,可以使用下面的命令進(jìn)行驗(yàn)證:
# 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 Thu 2018-07-12 10:50:29 CST; 6min agoDocs: man:firewalld(1) Main PID: 726 (firewalld) CGroup: /system.slice/firewalld.service└─726 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
可以看到Active: active (running),說明默認(rèn)的firewalld已經(jīng)在運(yùn)行了。
# systemctl status iptables Unit iptables.service could not be found.
說明沒有安裝iptables。
關(guān)閉防火墻:
# systemctl stop firewalld
此時(shí)如果重新執(zhí)行systemctl status firewalld,可以看到狀態(tài)為:Active: inactive (dead)
禁止開機(jī)啟動(dòng):
# systemctl disable firewalld Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
打開防火墻
# systemctl start firewalld
設(shè)置開機(jī)啟動(dòng)
# systemctl enable smb.serviceln -s '/usr/lib/systemd/system/smb.service' '/etc/systemd/system/multi-user.target.wants/smb.service'。created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.。created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.。
以后有時(shí)間再寫防火墻規(guī)則的查看、增加、刪除。