LoginSignup
253
271

More than 5 years have passed since last update.

5分で終わらせるCentOS7のfirewalld設定

Posted at

CentOS7からファイアウォールの設定が「iptables」から「firewalld」に変更となりました。5分でfirewalldの設定を完了するための方法です。

firewalldの開始と停止

firewalldの開始、終了、ステータス
# status
systemctl status firewalld

# start
systemctl start firewalld

# stop
systemctl stop firewalld

mysqlとsshからの通信を許可する設定例

firewalldの設定変更
# 有効な設定を確認
>>> firewall-cmd --list-services --zone=public  --permanent     
dhcpv6-client

# 設定追加(sshとmysqlを追加)
firewall-cmd --add-service=ssh --zone=public --permanent
firewall-cmd --add-service=mysql --zone=public --permanent

# 設定削除(sshを削除)
firewall-cmd --remove-service=ssh --zone=public --permanent

# 設定一覧を表示
ls -lta /usr/lib/firewalld/services/

# 各設定毎の内容確認
cat /usr/lib/firewalld/services/ssh.xml

# 設定をカスタマイズする(ポート変更とか)
cp /usr/lib/firewalld/services/ssh.xml /etc/firewalld/services/
vi /etc/firewalld/services/ssh.xml
firewall-cmd --reload  # 設定反映

# 有効な設定を確認
>>> firewall-cmd --list-services --zone=public  --permanent     
dhcpv6-client mysql ssh

独自設定を追加

こちらのページが参考になりました。
CentOS7のfirewalldをまじめに使うはじめの一歩(systemdも少し)

253
271
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
253
271