Linuxの下のファイアウォールとselinuxの起動、閉じる、表示


CentOS7.Xの下:
1.ファイアウォール
ファイアウォールステータスの表示:
[root@localhost sunan]# systemctl status firewalld.service
● 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)

ここでActiveはinactive(dead)がオフ、active(running)がオン
ファイアウォールを閉じるコマンド:
[root@localhost sunan]# systemctl stop firewalld.service 

ファイアウォールを開くコマンド:
[root@localhost sunan]# systemctl start firewalld.service

ファイアウォールコマンドを永続的に無効にする(起動してから起動しない)
[root@localhost sunan]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

ファイアウォールコマンドを永続的に起動(POST)
[root@localhost sunan]# systemctl enable firewalld.service   
Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.

CentOS6.Xの下:
1.ファイアウォール
ファイアウォールステータスの表示:
[root@localhost ~]# service iptables status

ファイアウォールを閉じるコマンド:
[root@localhost ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]

ファイアウォールを開くコマンド:
[root@localhost ~]# service iptables start
iptables: Applying firewall rules:                         [  OK  ]

ファイアウォールコマンドを永続的に無効にする(起動してから起動しない)
[root@localhost ~]# chkconfig iptables off

ファイアウォールコマンドを永続的に起動(POST)

[root@localhost ~]# chkconfig iptables on

2.selinux(CentOS 7.XとCentOS 6.X)
selinuxステータスを表示するには、次の手順に従います.
[root@localhost sunan]# getenforce 
Enforcing

selinuxステータスには、selinuxの実行中を表すenforcing:強制モードの3つのモードがあり、domain/typeが正しく制限されています.permissive:寛容モードで、selinux動作中を表しますが、domain/typeへのアクセスは実際に制限されません.このモードはselinuxのdebugとしてdisabledを使用することができます:閉じて、selinuxは実際に実行されていません.コマンドはSELinuxを設定し、disabled状態ではないことを前提とします.
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce  
Permissive

ここでsetenforce 0|10:premissive状態に設定する;1:enforcing状態に設定します.この設定:システムを再起動しても無効です.プロファイルを変更し、selinuxをdisabled状態に設定します.
[root@localhost ~]# vim /etc/selinux/config

SELINUX=disabled
SELINUXTYPE=targeted

保存し、システムを再起動して有効にします.