random-archer / mkinitcpio-systemd-tool

Provisioning tool for systemd in initramfs (systemd-tool)
https://www.archlinux.org/packages/community/any/mkinitcpio-systemd-tool/
Other
112 stars 27 forks source link

UUID used for DHCP request instead of real MAC address #80

Open fedegiova opened 3 years ago

fedegiova commented 3 years ago

Hi, I've almost succeded to configure the mkinitcpio to remote unlock a luks volume, the remaining issue is that in the initramfs context the DHCP requests made to acquire a lease from the DHCP server are make using an UUID instead of the ethernet device's MAC address. This means that the IP address of the PC is jumping around the subnet at every reboot.

I've found some information on the topic but I haven't managed to fix it,

my initrd-network

[Match]

# use kernel interface names
Name=eth*

# TODO use predictable network interface names
#Name=en*

[Network]
DHCP=ipv4

[DHCP]
UseHostname=true
Anonymize=false

It's the stock one but I've added the Anonymize=false option without success, note that the MAC of the card is not changed, ip a still show the correct one, it's just not used for the DHCP request which uses a much longer UUID o sort of.

I've found that using UUID for DHCP requests it's a feature of networkmanager: https://www.reddit.com/r/archlinux/comments/6ls9gn/how_to_disable_random_mac_address/ but actually we're not using network manager, I've also searched in the man page of systemd-networkd but found no way to disable the behaviour.

Any clue?

Regards Federico

Andrei-Pozolotin commented 3 years ago

1) it seems that your network usage case is not initrd - specific

2) perhaps it would be easier to debug this setup outside of initrd and then apply discovered settings to the initrd-network.network file

kittydoor commented 4 months ago

I'm also struggling from this (at least the symptom of jumping addresses, not sure if the same underlying cause) on my own setup. I'm not sure what further steps to take to diagnose and resolve as I'm not familiar with the nuance of the environment all of this is running in (as opposed to after full system boot is complete). Can anyone provide help / directions?

Andrei-Pozolotin commented 4 months ago

to verify if dhcp client or dhcp server is an issue: try to force the the same link mac address in both initrd and normal mode:

https://www.freedesktop.org/software/systemd/man/latest/systemd.link.html

for example, provide link files with these snippets:

/etc/systemd/network/initrd-network.link

# need to include into initrd build
[Link]
# Override MAC address (spoof MAC address)
MACAddress=11:22:33:44:55:66

/etc/systemd/network/normal-network.link

# need to include into existing or override the normal link
[Link]
# Override MAC address (spoof MAC address)
MACAddress=11:22:33:44:55:66

and also updated initrd-network.service to include initrd-network.link the image

# include network activated in initramfs
InitrdPath=/etc/systemd/network/initrd-network.link source=/etc/mkinitcpio-systemd-tool/network/initrd-network.link
InitrdPath=/etc/systemd/network/initrd-network.network source=/etc/mkinitcpio-systemd-tool/network/initrd-network.network
Andrei-Pozolotin commented 3 months ago

Another way to resolve this is to ensure the same mac-based ClientIdentifier in both initrd and normal system networks dhcp sections:

https://www.freedesktop.org/software/systemd/man/latest/systemd.network.html#ClientIdentifier=

[DHCPv4]
ClientIdentifier=mac