Repository navigation
Description
systemd version the issue has been seen with
242, 243
Used distribution
Debian 10, Fedora Core 31
Unexpected behaviour you saw
Suppose we have an interface with DHCP=ipv4 and Anonymize=true, successfully configured with DHCP. Then the link loses carrier for some reason (we pull out a cable or stop wpa_supplicant). Then we change MAC address on the interface, start tshark and restore the link.
In a sniffer log we can see that networkd send Discovery packet containing Option 50 with an IP address offered before. With a new MAC it is unlikely we get same IP address. On the other hand, we don't want to show our last IP address to DHCP server.
Expected behaviour you didn't see
When Anonymize=true is set and MAC address of an interface has been changed, Discovery packet should contain no IP address.
Steps to reproduce the problem
First stage
- Disconnect a link
systemctl restart systemd-networkd- stark
tsharkin another console - Connect a link
The dump shows no previous IP address because we restarted netwokrd:
Bootstrap Protocol (Discover)
Message type: Boot Request (1)
…
Your (client) IP address: 0.0.0.0
…
Client MAC address: 8a:74:2e:50:6c:c3
…
Option: (53) DHCP Message Type (Discover)
Length: 1
DHCP: Discover (1)
Option: (61) Client identifier
Length: 7
Hardware type: Ethernet (0x01)
Client MAC address: 8a:74:2e:50:6c:c3
…
Option: (255) End
Option End: 255
Received 192.168.118.145
Bootstrap Protocol (Offer)
Message type: Boot Reply (2)
…
Your (client) IP address: 192.168.118.145
…
Client MAC address: 8a:74:2e:50:6c:c3
…
Option: (53) DHCP Message Type (Offer)
Length: 1
DHCP: Offer (2)
…
Second stage
- Disconnect a link
- Change MAC address using
macchanger -r enp0s3or justip link set enp0s3 down/address/up - Run
tsharkagain - Connect a link
Discover packet contains IP address 192.168.118.145 (we don't want to reveal it) offered before:
Bootstrap Protocol (Discover)
Message type: Boot Request (1)
…
Client IP address: 0.0.0.0
Your (client) IP address: 0.0.0.0
…
Client MAC address: c6:6d:32:bb:9b:9c
…
Option: (53) DHCP Message Type (Discover)
Length: 1
DHCP: Discover (1)
Option: (61) Client identifier
Length: 7
Hardware type: Ethernet (0x01)
Client MAC address: c6:6d:32:bb:9b:9c
…
Option: (50) Requested IP Address
Length: 4
Requested IP Address: 192.168.118.145
Option: (255) End
Option End: 255
DHCP server offers a different (as expected) IP address 192.168.118.127.
Bootstrap Protocol (Offer)
Message type: Boot Reply (2)
…
Your (client) IP address: 192.168.118.127
…
Client MAC address: c6:6d:32:bb:9b:9c
…
Option: (53) DHCP Message Type (Offer)
Length: 1
DHCP: Offer (2)
…
Activity
[-]networkd disclosures a previous IP address on DHCP discovery (Anonymize=true)[/-][+]networkd disclosures a previous IP address on DHCP discovery when MAC changed (Anonymize=true)[/+]ssahani commentedon Nov 15, 2019
How you change the Mac address?
mearsten commentedon Nov 15, 2019
It is described in the issue («Second stage», line «2»).
ssahani commentedon Nov 15, 2019
networkd either controls the interface fully or not. So please don't use third party tool that would be a race.
mearsten commentedon Nov 15, 2019
It is not third-party tool. It is native Linux iproute2 tool.
I have looked into the code. It looks like https://github.com/systemd/systemd/blob/v243/src/libsystemd-network/sd-dhcp-client.c#L801 should be changed like this:
Anyway option 50 in the Discovery is not very userful.
ssahani commentedon Nov 16, 2019
I mean it should be changed via networkd not via other tool. It just one case you pointing. I am pretty sure there are tons of cases will arise like this. Hence will be difficult to track. I think you can understand what I mean.
mearsten commentedon Nov 16, 2019
There is no networkctl command to change MAC. Am I missed something?
ssahani commentedon Nov 16, 2019
not via networkctl but via
.network. please see .https://www.freedesktop.org/software/systemd/man/systemd.network.html#MACAddress=1mearsten commentedon Nov 16, 2019
I want to change MAC right away. It is a simple operation, and Linux native tool iproute2 allows to do that.
You suggest me to change text file .network, then restart a service? 2 acts instead of 1? It looks like an overengineering.
Moreover, networkd claims that it controls the network in a declarative way. If we don't use
MACAddress=key then networkd shouldn't care about MAC.An it actually doesn't care in that case. But DHCP code just remembers the previous IP address and sends it unconditionally. We should add a condition. It is a quite correct solution of a problem.
The issue is not just a bug. It describes a use case. Computers were created for people. The opposite is incorrect.
Networkd is a 3rd party tool. It is an optional part for Linux and it behaves a little bit incorrect in a correct environment.
The solution is very simple: change just 1 line I mentioned before. I won't break anything.
I can make a PR if it is going to be accepted.
ssahani commentedon Nov 16, 2019
Please this feature is already available with network. Hence I do not agree change with iproute. Rather we can add this feature via networkctl. Via networkctl it will talk to networkd via dbus. Then it should make the changes to the conf files also. networkd either takes control of the interface or not.
It is very simple what is so difficult in this.
Why it should ? Please make changes in .network file. We allowed such cases for keepalived with
KeepConfiguration=The MAC won't be persistent. I would rather like to do it via networkctl and make changes to the .network file and should be persistent.
mearsten commentedon Nov 16, 2019
There is another point of view. RFC7844 says:
Message Type is option 53
Client Identifier is option 61
Parameter Request List is option option 55
So option 50 (== "any other option") should not be included into Discovery message when
Anonymize=true.How to achieve that? Just change that 1 line of code I mentioned before.
It is an overengineering.
It doesn't take control and it can't do that all the time. It just «detects and configures network devices as they appear, as well as creating virtual network devices.» (man 8 systemd-networkd).
A have read the documentation. This option has nothing to do with the issue.
It should not be persistent. I use this:
in a
.linkfile. Works OK.ssahani commentedon Nov 16, 2019
I strongly object such nuisance words against networkd . I can't continue engage myself with such individuals . This is not a bug by anyway.. This feature already available with networkd. I don't not think this should be entertained. Hence I am unsubscribing from this issue. Thank you.
sd-dhcp-client: anonymize DHCPDISCOVER (fixes systemd#13992)
sd-dhcp-client: anonymize DHCPDISCOVER (fixes #13992)