RHEL 9.3 Nftables サービスを有効化する方法

環境
Red Hat Enterprise Linux release 9.2

操作方法
1.nftables は Firewalld のデフォルトのバックエンドとして使用されています。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# grep nftables /etc/firewalld/firewalld.conf
# - nftables (default)
FirewallBackend=nftables
# grep nftables /etc/firewalld/firewalld.conf # - nftables (default) FirewallBackend=nftables
# grep nftables /etc/firewalld/firewalld.conf
# - nftables (default)
FirewallBackend=nftables

2.nftables を使用する場合は、firewalld サービスは無効化します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
# systemctl disable --now firewalld Removed /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

3.システムの再起動時にフィルタリングのルールセットを復元できるように、nftables のサービスを有効化します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# systemctl enable --now nftables
Created symlink /etc/systemd/system/multi-user.target.wants/nftables.service → /usr/lib/systemd/system/nftables.service.
# systemctl enable --now nftables Created symlink /etc/systemd/system/multi-user.target.wants/nftables.service → /usr/lib/systemd/system/nftables.service.
# systemctl enable --now nftables
Created symlink /etc/systemd/system/multi-user.target.wants/nftables.service → /usr/lib/systemd/system/nftables.service.

4.[nftables.service] は起動時に [/etc/sysconfig/nftables.conf] を読み込んでルールセットを復元するサービス
# systemctl cat nftables.service

5. [/etc/sysconfig/nftables.conf] はデフォルトでは設定なし
# cat /etc/sysconfig/nftables.conf

6.Firewalld の現在の設定確認 ( firewalld サービス稼働中が前提 )

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# firewall-cmd --list-all
# firewall-cmd --list-all
# firewall-cmd --list-all

Firewalld バックエンドの nftables の現在のルールセットを全て表示
# nft list ruleset

現在のルールセットを [/etc/sysconfig/nftables.conf] に書き出す
# nft list ruleset > /etc/sysconfig/nftables.con
# firewalld サービス停止 & nftables サービス起動

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# systemctl disable --now firewalld
# systemctl enable --now nftables
# systemctl disable --now firewalld # systemctl enable --now nftables
# systemctl disable --now firewalld
# systemctl enable --now nftables

# ルールセット表示
# nft list ruleset

RHEL9

Posted by arkgame