[root@hanfeng-001 ~]# vi /etc/selinux/config 將SELINUX=enforcing更改成SELINUX=disabled 而後在重啓系統,就會永久關閉selinux (如果將SELINUXTYPE=targeted 這裏更改了,就會沒法開啓系統!!!千萬注意)
[root@hanfeng-001 ~]# getenforce Enforcing [root@hanfeng-001 ~]# setenforce 0 //臨時關閉 [root@hanfeng-001 ~]# getenforce Permissive [root@hanfeng-001 ~]#
netfilter防火牆是centos7以前的叫法linux
在centos7的時候,叫作firewalldcentos
這 netfilter 和firewalld 兩個防火牆機制不太同樣,但內部的工具(iptables)用法是同樣的安全
在centos7中,默認使用的是firewalld,而netfilter防火牆是沒有開啓的運維
關閉firewalld [root@hf-01 ~]# systemctl disable firewalld //停掉firewalld,就是限制開機啓動 Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service. [root@hf-01 ~]# systemctl stop firewalld //關閉firewalld服務 開啓netfilter 在開啓以前,須要先安裝一個iptables-services包 [root@hf-01 ~]# yum install -y iptables-services [root@hf-01 ~]# systemctl enable iptables //設置開啓激動 Created symlink from /etc/systemd/system/basic.target.wants/iptables.service to /usr/lib/systemd/system/iptables.service. [root@hf-01 ~]# systemctl start iptables //開啓iptables服務 [root@hf-01 ~]#
[root@hf-01 ~]# iptables -nvL //查看默認規則 Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 35 2436 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT 22 packets, 3152 bytes) pkts bytes target prot opt in out source destination [root@hf-01 ~]#