Voici le script systemd lançant libvirtd.

# cat /lib/systemd/system/libvirtd.service
[Unit]
Description=Virtualization daemon
Requires=virtlogd.socket
Requires=virtlockd.socket
# Use Wants instead of Requires so that users
# can disable these three .socket units to revert
# to a traditional non-activation deployment setup
Wants=libvirtd.socket
Wants=libvirtd-ro.socket
Wants=libvirtd-admin.socket
Wants=systemd-machined.service
After=network.target
After=firewalld.service
After=iptables.service
After=ip6tables.service
After=dbus.service
After=iscsid.service
After=apparmor.service
After=local-fs.target
After=remote-fs.target
After=systemd-logind.service
After=systemd-machined.service
After=xencommons.service
Conflicts=xendomains.service
Documentation=man:libvirtd(8)
Documentation=https://libvirt.org

[Service]
Type=notify
Environment=LIBVIRTD_ARGS="--timeout 120"
EnvironmentFile=-/etc/default/libvirtd
ExecStart=/usr/sbin/libvirtd $LIBVIRTD_ARGS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
# At least 1 FD per guest, often 2 (eg qemu monitor + qemu agent).
# eg if we want to support 4096 guests, we'll typically need 8192 FDs
# If changing this, also consider virtlogd.service & virtlockd.service
# limits which are also related to number of guests
LimitNOFILE=8192
# The cgroups pids controller can limit the number of tasks started by
# the daemon, which can limit the number of domains for some hypervisors.
# A conservative default of 8 tasks per guest results in a TasksMax of
# 32k to support 4096 guests.
TasksMax=32768
# With cgroups v2 there is no devices controller anymore, we have to use
# eBPF to control access to devices.  In order to do that we create a eBPF
# hash MAP which locks memory.  The default map size for 64 devices together
# with program takes 12k per guest.  After rounding up we will get 64M to
# support 4096 guests.
LimitMEMLOCK=64M

[Install]
WantedBy=multi-user.target
Also=virtlockd.socket
Also=virtlogd.socket
Also=libvirtd.socket
Also=libvirtd-ro.socket



Il contient deux références à firewalld.service et iptables.service mais j'ai:
# systemctl status iptables firewalld
Unit iptables.service could not be found.
Unit firewalld.service could not be found.


Voyez-vous dans /lib/systemd/system/libvirtd.service, un élément
lançant la configuration de nftables/iptables ?

Le mer. 22 janv. 2025 à 11:07, Olivier <oza.4...@gmail.com> a écrit :
>
> Merci à tous pour vos réponses, que je n'ai pas encore eu le temps de
> décortiquer.
> Je vais prendre le temps de le faire.
>
> Pour bien rappeler mon problème, j'observe que sur sur machine
> hébergeant libvirt/qemu, dès règles sont ajoutées au firewall mais je
> n'arrive pas à voir comment elles sont activées.
> D'habitude, pour le firewall, j'ajoute un script exécutable dans
> /etc/network/if-pre-up.d et il est lancé au démarrage.
>
> Là, c'est probablement le daemon libvirtd qui active ces règles mais
> je n'en suis pas sûr et je n'arrive pas à comprendre comment il le
> fait.
>
> Le mer. 22 janv. 2025 à 08:59, Basile Starynkevitch
> <bas...@starynkevitch.net> a écrit :
> >
> > On Tue, 2025-01-21 at 18:59 +0100, NoSpam wrote:
> > > Bonsoir.
> > >
> > > Pour ma part j'utilise les hooks de libvirt en faisant un nft flush
> > > ruleset && nft -f mesRegles après que les interfaces libvirt soient 
> > > montées.
> > >
> > > Bien évidemment mon fichier mesRegles contient les règles de libvirt qui
> > > ont été sauvegardées au préalable. Je pense que cela doit même pouvoir
> > > se faire avant le flush.
> > >
> > > L'autre solution est de créer ses règles dans des tables diffŕentes que
> > > celles de libvirt.
> > >
> > > Le 21/01/2025 à 16:14, Olivier a écrit :
> > > > Bonjour,
> > > >
> > > > J'ai une machine sous Bookworm, qui fait office d'hôte libvirt.
> > > > Elle héberge une ou deux VM.
> > > >
> > > > J'ai besoin de changer son adressage en lui donnant un IP publique.
> >
> > Probablement le paquet fail2ban est pertinent.
> > --
> > Basile STARYNKEVITCH           <bas...@starynkevitch.net>
> > 8 rue de la Faïencerie
> > 92340 Bourg-la-Reine,          France
> > http://starynkevitch.net/Basile & https://github.com/bstarynk
> >

Répondre à