From 9402c6040517a8b37516be8304b61e125965cfc0 Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Mon, 2 Sep 2024 12:47:43 +0200 Subject: [PATCH] systemd-networkd: default to DUIDType=link-layer for ipv6; via networkd.conf.d - only affects systemd-networkd-using builds (MINIMAL images?) - does NOT affect NetworkManager - this allows network administrators to give out IPv6 addresses over DHCPv6 based on the MAC address (which should be stable) instead of systemd's own notion of it's "DUID", which is based on the machine-id and changes on every redeployment --- .../systemd/networkd.conf.d/mac-duid.conf | 9 +++++++++ extensions/network/net-systemd-networkd.sh | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 extensions/network/config-networkd/systemd/networkd.conf.d/mac-duid.conf diff --git a/extensions/network/config-networkd/systemd/networkd.conf.d/mac-duid.conf b/extensions/network/config-networkd/systemd/networkd.conf.d/mac-duid.conf new file mode 100644 index 000000000000..b336599b790e --- /dev/null +++ b/extensions/network/config-networkd/systemd/networkd.conf.d/mac-duid.conf @@ -0,0 +1,9 @@ +# Use LL (link-layer, sans timestamp) DUIDs for DHCP. +# It is the default for v4, but not for v6. +# Having it set to LL allows network admins to do MAC-based reservations for v6 the same way there's done for v4. +# If the MAC address of an interface is 01:02:03:04:05:06, then the DUID will be 00030001010203040506 +[DHCPv4] +DUIDType=link-layer + +[DHCPv6] +DUIDType=link-layer diff --git a/extensions/network/net-systemd-networkd.sh b/extensions/network/net-systemd-networkd.sh index cf6de67fc78c..a059b77b4b7e 100644 --- a/extensions/network/net-systemd-networkd.sh +++ b/extensions/network/net-systemd-networkd.sh @@ -24,12 +24,19 @@ function pre_install_kernel_debs__configure_systemd_networkd() { local netplan_config_src_folder="${EXTENSION_DIR}/config-networkd/netplan/" local netplan_config_dst_folder="${SDCARD}/etc/netplan/" + run_host_command_logged cp -v "${netplan_config_src_folder}"* "${netplan_config_dst_folder}" + local networkd_config_src_folder="${EXTENSION_DIR}/config-networkd/systemd/network/" local networkd_config_dst_folder="${SDCARD}/etc/systemd/network/" - run_host_command_logged cp -v "${netplan_config_src_folder}"* "${netplan_config_dst_folder}" run_host_command_logged cp -v "${networkd_config_src_folder}"* "${networkd_config_dst_folder}" + local networkd_conf_d_config_src_folder="${EXTENSION_DIR}/config-networkd/systemd/networkd.conf.d/" + local networkd_conf_d_config_dst_folder="${SDCARD}/etc/systemd/networkd.conf.d/" + + mkdir -p "${networkd_conf_d_config_dst_folder}" # This doesn't exist by default, create it + run_host_command_logged cp -v "${networkd_conf_d_config_src_folder}"* "${networkd_conf_d_config_dst_folder}" + # Change the file permissions according to https://netplan.readthedocs.io/en/stable/security/ chmod -v 600 "${SDCARD}"/etc/netplan/* }