Skip to content

Commit

Permalink
systemd-networkd: default to DUIDType=link-layer for ipv6; via networ…
Browse files Browse the repository at this point in the history
…kd.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
  • Loading branch information
rpardini authored and igorpecovnik committed Sep 14, 2024
1 parent ef537a6 commit 1b4e19d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
9 changes: 8 additions & 1 deletion extensions/network/net-systemd-networkd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
}

0 comments on commit 1b4e19d

Please sign in to comment.