NetworkConfiguration / dhcpcd

DHCP / IPv4LL / IPv6RA / DHCPv6 client.
https://roy.marples.name/projects/dhcpcd
BSD 2-Clause "Simplified" License
347 stars 111 forks source link

dhcpcd 10.0.5 needs restart when MAC changes #303

Open juhaj opened 8 months ago

juhaj commented 8 months ago

The behaviour of dhcpcd when the interface MAC changes is odd. It seems that dhcpcd tries to use whatever MAC the interface had when dhcpcd started even if it has been changed since e.g. by iwd when changing to a different wifi AP. Sometimes dhcpcd just simply stops sending requests at all and neither dhcpcd --rebind nor dhcpcd --renew causes it to send a new one.

My expectation would be that this sequence (both dhcpcd and iwd are running) gets me a new IP on the new wifi:

dhcpcd --release # I need to do this because I have "persistent" turned on in the config file
iwctl station wlan0 disconnect
iwctl station wlan0 connect some_other_AP_different_from_current
dhcpcd --renew

but instead I only get the IPv6 RA stateless addresses (if the network of the new AP has any). If I instead restart the whole daemon, things work:

dhcpcd --release
dhcpcd --exit
iwctl station wlan0 disconnect
iwctl station wlan0 connect some_other_AP_different_from_current
dhcpcd -b

It looks to me as if dhcpcd reads the LL address once at startup and if that changes (as it will on most modern systems when changing networks), it does not notice and reread the new value.

The config file is the default supplied (comments removed), though I tried quite a few different options, too:

duid
persistent
vendorclassid
option domain_name_servers, domain_name, domain_search
option classless_static_routes
option interface_mtu
option host_name
option rapid_commit
require dhcp_server_identifier
slaac private

Another oddity is that the RA-derived addresses of the old network are not deleted - I would have expected them to be deleted, but maybe that is iwd's job when it disconnects the AP?

rsmarples commented 8 months ago

You should not need to do anything with dhcpcd, it listens to carrier changes. It also listens to hardware (MAC) address changes just fine which IIRC can only be made when the interface is in the down state. You've not said what dhcpcd version you're running? I do recall changing how carrier works on Linux wireless recently and that latest version reflects that.