Fedora 34
Sponsored Link

初期設定 : ファイアウォール2021/04/28

 
ファイアウォールと SELinux の設定についてです。
[1] ファイアウォールサービスの現在の状態は以下のようにして確認できます。(デフォルトは有効)
[root@localhost ~]#
systemctl status firewalld

* firewalld.service - firewalld - dynamic firewall daemon
     Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor>
     Active: active (running) since Wed 2021-04-27 19:14:58 JST; 3min 53s ago
       Docs: man:firewalld(1)
   Main PID: 680 (firewalld)
      Tasks: 2 (limit: 4664)
     Memory: 37.0M
        CPU: 693ms
     CGroup: /system.slice/firewalld.service
             +-- 680 /usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid

# Active: active (running) *** の状態は稼働中

[2]
ファイアウォールサービスを利用する場合、デフォルトではインバウンド通信はほぼ許可されていないため、 サーバーに設定/公開するサービス/アプリケーションに応じて、許可の設定が必要になります。
ファイアウォールサービスの基本的な操作/設定方法はこちらを参照ください (CentOS Stream 8)
なお、当サイトの Fedora 34 設定例は、全て、ファイアウォールサービス稼働中の環境を前提としていますので、各ページには必要に応じて許可設定を記載しています。
[3] もし、自身のネットワーク内で、設定対象とするサーバーの上位にファイアウォール機器が設置されており、 サーバー側ではファイアウォールサービスは必要ないといった場合は、以下のようにして停止可能です。
# サービス停止

[root@localhost ~]#
systemctl stop firewalld

# 自動起動設定を無効にする

[root@localhost ~]#
systemctl disable firewalld

Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
初期設定 : SELinux
[4] SELinux (Security-Enhanced Linux) の現在の状態は以下のようにして確認できます。(デフォルトは有効)
[root@localhost ~]#
getenforce

Enforcing     # SELinux は有効な状態
[5]
SELinux を利用する場合、通常の Linux アクセス権の設定は問題なくとも、SELinux のアクセス制御によってアクセスが拒否され、サービス/アプリケーションが期待通りの動作をしないといった場合が発生します。 そのため、サーバーに設定/公開するサービス/アプリケーションによっては、SELinux ポリシーに対して、手動でのアクセス許可の設定が必要になる場合があります。
SELinux の基本的な操作/設定方法はこちらを参照ください (CentOS Stream 8)
なお、当サイトの Fedora 34 設定例は、全て、[SELinux = Enforcing] の環境を前提としていますので、各ページには必要に応じて許可設定を記載しています。
[6] もし、設定対象とするサーバーが安全な社内のみの利用である等の理由で SELinux を無効にしたいといった場合は、以下のように設定して無効化できます。
[root@localhost ~]#
vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
# See also:
# https://docs.fedoraproject.org/en-US/quick-docs/getting-started-with-selinux/#getting-started-with-selinux-selinux-states-and-modes
#
# NOTE: In earlier Fedora kernel builds, SELINUX=disabled would also
# fully disable SELinux during boot. If you need a system with SELinux
# fully disabled instead of SELinux running with no policy loaded, you
# need to pass selinux=0 to the kernel command line. You can use grubby
# to persistently set the bootloader to boot with selinux=0:
#
#    grubby --update-kernel ALL --args selinux=0
#
# To revert back to SELinux enabled:
#
#    grubby --update-kernel ALL --remove-args selinux
#
# 必要に応じて下行を変更
# enforcing  ⇒ 有効
# disabled   ⇒ 無効
# permissive ⇒ 有効だがロギングのみでアクセス拒否はされない
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

# 再起動して変更を有効にする

[root@localhost ~]#
関連コンテンツ