RHEL系 ファイヤーウォールサービスの停止方法
RHEL系(Centos7以降、RockyLinux,AlmaLinux)の初期設定で有効になっているfirewalldサービスの停止及び自動起動を停止、再度自動起動を有効にする方法を記載。
RHEL Fedora CentOS7以降 Rocey Alma
RHEL系ではインストール直後の初期状態からファイヤーウォールが有効となっています。WebサーバーやSSH、データベースサーバーをインストールし、別の端末からアクセスしたい場合、ファイヤーウォールによって接続できない等のトラブルがよくあるので、インストール直後は一度、ファイヤーウォールを無効にしておくと良いでしょう。
基本的に、セキュリティ関連の設定や構築はサーバー構築(ミドルウェアインストールや設定)と動作検証が終わった最終工程で作業したほうが、ハマらずに済みます。(ミドルウェアの設定不備なのか、ファイヤーウォールなのか切り分けに手間がかかる)そのため、初期構築時はすべてオフにしておくことを勧めします。
firewalld自動起動設定確認
systemctl is-enabled firewalld

念のためiptables自動起動を確認します。
systemctl is-enabled iptables

CentOS6までは「iptables」を使用してましたが、CentOS7以降は「firewalld」に置きまわっています。
firewalldサービス停止と確認
「systemctl stop firewalld」コマンドで現在稼働している「firewalld」サービスを停止します。
コマンドは管理者権限で実行する必要があります。su-でrootにスィッチするか、sudoで実行します。
systemctl stop firewalld
サービスが停止された確認を行います。
systemctl status firewalld

Active欄が「Active: inactive(dead)」と表示されていることを確認。また、Active: active (running)と表示されている場合は、firewalldが起動しています。
firewalld自動起動停止
サーバーの再起動後に「firewalld」サービスが自動で起動してしまうので、systemctlコマンドで自動を停止します。
コマンドは管理者権限で実行する必要があります。su-でrootにスィッチするか、sudoで実行します。
systemctl disable firewalld

systemctl disable firewalld
設定の確認
自動起動が停止されていることを「systemctl is-enabled firewalld」コマンドで確認します。
systemctl is-enabled firewalld
実行結果

再度有効にする方法
再度、停止させたfirewalldサービスを起動するには、「systemctl enable firewalld」コマンドを実行します。
systemctl enable firewalld

自動起動が正常に設定されているか、「systemctl is-enabled firewalld」で確認します。
systemctl is-enabled firewalld
