]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: configure a tun host0 interface in a container
authorHelmut Grohne <helmut@subdivi.de>
Wed, 15 May 2024 05:21:53 +0000 (07:21 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 16 May 2024 12:37:28 +0000 (14:37 +0200)
While containers often have their host0 network provided by veth when
the container runtime is privileged, unprivileged containers tend to
have their network provided via slirp4netns or pasta. These tools use a
tun interface rather than a veth interface and systemd should still set
configure such networks.

We should have different .network files for the veth and tun use cases
as there may arise a need to configure them differently.  We should not
rename 80-container-host0.network as that would cause existing drop-ins
to no longer apply.

Closes: #32095
Fixes: f139393dd20a ("network: use Kind= instead of Driver=")
Signed-off-by: Helmut Grohne <helmut@subdivi.de>
network/80-container-host0-tun.network [new file with mode: 0644]
network/meson.build

diff --git a/network/80-container-host0-tun.network b/network/80-container-host0-tun.network
new file mode 100644 (file)
index 0000000..1a50512
--- /dev/null
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: MIT-0
+#
+# This config file is installed as part of systemd.
+# It may be freely copied and edited (following the MIT No Attribution license).
+#
+# To make local modifications, use "networkctl edit". See networkctl(1) for details.
+# This file should not be edited in place, because it'll be overwritten on upgrades.
+
+# This network file is inside unprivileged containers that rely on network being
+# provided as a tun link via slirp4netns(1) or pasta(1).
+
+[Match]
+Kind=tun
+Name=host0
+Virtualization=container
+
+[Network]
+DHCP=yes
+LinkLocalAddressing=yes
+
+[DHCP]
+UseTimezone=yes
index 1141b178447a6fc2ac9d52e773826e4af151702c..6231d55351072ba38981622e3015e59f43aab669 100644 (file)
@@ -5,6 +5,7 @@ if conf.get('ENABLE_NETWORKD') == 1
                 '80-6rd-tunnel.network',
                 '80-6rd-tunnel.link',
                 '80-container-host0.network',
+                '80-container-host0-tun.network',
                 '80-container-vb.network',
                 '80-container-vb.link',
                 '80-container-ve.network',