デフォルトでは、RHEL 7 は FirewallD サービスを使用してネットワーク セキュリティを提供します。 Firewalld は万人に好まれるわけではなく、iptables が好まれるかもしれません。 iptables サービスを使用する場合は、FirewallD を停止して無効にする必要があります。この投稿では、CentOS/RHEL 7 で firewalld を無効にして iptables を有効にする手順の概要を説明しています。
firewalld を停止して無効にする
1. まず、Firewalld を無効にして、起動時に再起動しないようにする必要があります。
# systemctl stop firewalld # systemctl disable firewalld
2. firewalld サービスをマスキングすると、/etc/systemd/system/firewalld.service から /dev/null へのシンボリック リンクが作成され、firewalld サービスが無効になります。
# systemctl mask firewalld Created symlink from /etc/systemd/system/firewalld.service to /dev/null.
iptables のインストールと構成
1. iptables を有効にするには、まず「iptables-services」をインストールする必要があります。 」パッケージ。
# yum install iptables-services
2. 起動時に iptables サービスを開始して有効にし、起動時に自動的に有効にします。
# systemctl start iptables # systemctl enable iptables
firewalld から取り残されたルールがないかどうかを確認します。デフォルトでは、iptables の新規インストールには、以下に示すような iptables ルールがあります。
# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT icmp -- anywhere anywhere ACCEPT all -- anywhere anywhere ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) target prot opt source destination
残りのfirewalldルールをクリアする
1. 必要に応じて、次のコマンドを使用して、firewalld から残された iptables ルールをクリアできます。
# iptables -t nat -F # iptables -t mangle -F # iptables -F # iptables -X # service iptables save
2. 上記のコマンドを実行すると、以下に示すように空の iptable ルールが取得されます。
# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destinationFirewalld コマンド ライン リファレンス (チート シート)
CentOS / RHEL 7 :iptables サービスと FirewallD サービスを同時に実行しないでください!