プライベートLANのセキュリティー設定

CentOSで、プライベートLAN側のセキュリティー設定についてのメモ。

1.現状のゾーン設定確認

以下コマンドで確認すると、プライベートネットワークeth1は、デフォルトのpublicになっている。

# firewall-cmd --get-active-zones
public
  interfaces: eth0 eth1

2.プライベート用のゾーン作成

プライベートネットワーク用のゾーンprivateを作成する。

https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/creating-a-new-zone_working-with-firewalld-zones

以下コマンドでOK。

firewall-cmd --new-zone=private --permanent

許可するサービスを追加。httpを追加の場合は以下。

firewall-cmd --permanent --zone=private --add-service=http

定義ファイル/etc/firewalld/zones/private.xmlを直接修正するでも良い。

https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/zone-configuration-files_working-with-firewalld-zones

以下は、ssh(※ポート変更済み)とnfsを有効とした場合。

<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>private</short>
  <description>private lan</description>
  <service name="ssh-XXXX"/>
  <service name="nfs"/>
</zone>

定義を読み込む。

firewall-cmd --reload

3.ゾーンへのネットワークインターフェースの割り当て

https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/assigning-a-network-interface-to-a-zone_working-with-firewalld-zones

firewall-cmd --zone=private --change-interface=eth1 --permanent

警告メッセージが出るので、以下でやる方がいいかもしれないが、上記コマンドで特に問題はない。

https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/assigning-a-zone-to-a-connection-using-nmcli_working-with-firewalld-zones

以下コマンドで、eth1に対しては、ゾーンprivateが適用されていることを確認。

# firewall-cmd --get-active-zones
public
  interfaces: eth0
private
  interfaces: eth1