再起動後にアクティブ化されたファイアウォールが再起動後にアクティブ化されたファイアウォールとは異なる動作をするのはなぜですか?

再起動後にアクティブ化されたファイアウォールが再起動後にアクティブ化されたファイアウォールとは異なる動作をするのはなぜですか?

ローリングリリースバージョンのCentos 8 Streamを使用していますが、奇妙で一貫性の4.18.0-301.1.el8.x86_64ない動作が発生します。

ファイアウォールの起動方法によって異なります。

  • 起動時にファイアウォールが起動すると、LIBVIRT_*チェーンが追加されます。

  • systemctlを使用してファイアウォールを再起動すると、これらのチェーンはすべて消えます。

  • なぜ?

# nftables after the reboot
$ nft list tables
table ip filter
table ip nat
table ip mangle
table ip6 filter
table ip6 nat
table ip6 mangle

# nftables after the systemctl restart
$ nft list tables
table ip filter
table ip nat
table ip mangle
table ip6 filter
table ip6 nat
table ip6 mangle
table bridge filter
table ip security
table ip raw
table ip6 security
table ip6 raw
table bridge nat
table inet firewalld
table ip firewalld
table ip6 firewalld
$ sudo iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
LIBVIRT_INP  all  --  0.0.0.0/0            0.0.0.0/0           

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
LIBVIRT_FWX  all  --  0.0.0.0/0            0.0.0.0/0           
LIBVIRT_FWI  all  --  0.0.0.0/0            0.0.0.0/0           
LIBVIRT_FWO  all  --  0.0.0.0/0            0.0.0.0/0           

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
LIBVIRT_OUT  all  --  0.0.0.0/0            0.0.0.0/0           

Chain LIBVIRT_INP (1 references)
target     prot opt source               destination         
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:53
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:53
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:67
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:67

Chain LIBVIRT_OUT (1 references)
target     prot opt source               destination         
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:53
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:53
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:68
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:68

Chain LIBVIRT_FWO (1 references)
target     prot opt source               destination         
ACCEPT     all  --  192.168.122.0/24     0.0.0.0/0           
REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachable

Chain LIBVIRT_FWI (1 references)
target     prot opt source               destination         
ACCEPT     all  --  0.0.0.0/0            192.168.122.0/24     ctstate RELATED,ESTABLISHED
REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachable

Chain LIBVIRT_FWX (1 references)
target     prot opt source               destination         
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0    

$ sudo systemctl restart firewalld

$ sudo iptables -L -n
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               destination       

これは非常に混乱し、デバッグが困難です。具体的には、openvpn-asサービスを開始した後にiptablesチェーンが追加されました。

ベストアンサー1

firewalldこれらのチェーンを追加することは事実ではありません。チェーン名が示すように、チェーンは設定の上に追加されますlibvirtfirewalld

CentOS 8 Streamの工場出荷時の基本構成には、仮想マシン(またはCentOS 8システム自体が仮想マシンの場合はネストされた仮想化)を実行するためのいくつかの準備が含まれています。 CentOSで仮想マシンを実行する必要がない場合は、無効にする必要があります。

現在、CentOS 8 Streamテストシステムはありませんが、これが役に立つと思います。

virsh net-destroy default              # unconfigure what libvirtd has done for now
systemctl stop libvirtd.service        # stop the service
systemctl disable libvirtd.service     # persistently disable it

何らかの目的で実行を続けたいが、デフォルトのlibvirtdネットワーク設定を無効にしたい場合は、次のようにすることができます(ただし、これがiptablesの追加を消去するかどうかはわかりません)。

virsh net-destroy default           # unconfigure what libvirtd has done for now
virsh net-undefine default          # persistently remove libvirtd network config

または、単に:(libvirtdを再インストールしたり、デフォルト設定を復元しないと元に戻すことはできません。)

virsh net-destroy default               # unconfigure what libvirtd has done for now
virsh net-autostart default --disable   # tell libvirt to not autostart default config

バージョン3を元に戻すには、オプションvirsh net-autostart defaultなしでバージョンを使用してサービスを再起動または再起動します。--disablelibvirtd

おすすめ記事