CentOS7にfirewalld の使い方

Firewallのインストール
#yum install firewalld firewalld-config

Firewallでポートを許可
#firewall-cmd –zone=public –add-port=80/tcp –permanent
#firewall-cmd –zone=public –add-port=443/tcp –permanent
#firewall-cmd –zone=public –add-port=22/tcp –permanent
#firewall-cmd –zone=public –add-port=21/tcp –permanent
#firewall-cmd –zone=public –add-port=53/udp –permanent

Firewallでポートを閉じる
#firewall-cmd –zone=public –remove-port=80/tcp –permanent
#firewall-cmd –zone=public –remove-port=443/tcp –permanent
#firewall-cmd –zone=public –remove-port=22/tcp –permanent
#firewall-cmd –zone=public –remove-port=21/tcp –permanent
#firewall-cmd –zone=public –remove-port=53/udp –permanent

Firewallで複数ポートを追加
#firewall-cmd –zone=public –add-port=4400-4600/udp –permanent
#firewall-cmd –zone=public –add-port=4400-4600/tcp –permanent

Firewallを有効する
#systemctl start firewalld.service

Firewallを再起動する
#firewall-cmd –reload 或者 service firewalld restart

ポートリストを確認する
#firewall-cmd –permanent –list-port

ポートを禁止
#systemctl stop firewalld

自動起動を有効
#systemctl enable firewalld

自動起動を無効
sytemctl disable firewalld

ステータスを確認
systemctl status firewalld
firewall-cmd –state

Linux

Posted by arkgame