Skip to content

networkd disclosures a previous IP address on DHCP discovery when MAC changed (Anonymize=true) #13992

Closed

Description

@mearsten

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
  1. Disconnect a link
  2. systemctl restart systemd-networkd
  3. stark tshark in another console
  4. 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
  1. Disconnect a link
  2. Change MAC address using macchanger -r enp0s3 or just ip link set enp0s3 down/address/up
  3. Run tshark again
  4. 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

  1. changed the title [-]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)[/+] on Nov 10, 2019
  2. added
    bug 🐛
    on Nov 11, 2019
  3. ssahani commented on Nov 15, 2019

    @ssahani
    Contributor

    How you change the Mac address?

  4. mearsten commented on Nov 15, 2019

    @mearsten
    ContributorAuthor

    How you change the Mac address?

    It is described in the issue («Second stage», line «2»).

  5. ssahani commented on Nov 15, 2019

    @ssahani
    Contributor

    networkd either controls the interface fully or not. So please don't use third party tool that would be a race.

  6. mearsten commented on Nov 15, 2019

    @mearsten
    ContributorAuthor

    third party tool

    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:

    -        if (client->last_addr != INADDR_ANY) {
    +        if (!client->anonymize && client->last_addr != INADDR_ANY) {
    

    Anyway option 50 in the Discovery is not very userful.

  7. ssahani commented on Nov 16, 2019

    @ssahani
    Contributor

    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.

  8. mearsten commented on Nov 16, 2019

    @mearsten
    ContributorAuthor

    should be changed via networkd

    There is no networkctl command to change MAC. Am I missed something?

  9. mearsten commented on Nov 16, 2019

    @mearsten
    ContributorAuthor

    but via .network

    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.

    mean it should be changed via networkd not via other tool

    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.

  10. ssahani commented on Nov 16, 2019

    @ssahani
    Contributor

    but via .network

    I want to change MAC right away. It is a simple operation, and Linux native tool iproute2 allows to do that.

    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.

    You suggest me to change text file .network, then restart a service? 2 acts instead of 1? It looks like an overengineering.

    It is very simple what is so difficult in this.

    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.

    Why it should ? Please make changes in .network file. We allowed such cases for keepalived with KeepConfiguration=

    mean it should be changed via networkd not via other tool

    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.

    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.

  11. mearsten commented on Nov 16, 2019

    @mearsten
    ContributorAuthor

    There is another point of view. RFC7844 says:

    DHCPDISCOVER: The anonymized DHCPDISCOVER messages MUST contain the
    Message Type option, MAY contain the Client Identifier option, and
    MAY contain the Parameter Request List option. It SHOULD NOT
    contain any other option.

    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.

    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.

    It is an overengineering.

    networkd either takes control of the interface or not.

    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).

    KeepConfiguration=

    A have read the documentation. This option has nothing to do with the issue.

    The MAC won't be persistent.

    It should not be persistent. I use this:

    [Link]
    MACAddressPolicy=random
    

    in a .link file. Works OK.

  12. ssahani commented on Nov 16, 2019

    @ssahani
    Contributor

    Networkd is a 3rd party tool. It is an optional part for Linux and it behaves a little bit incorrect in a correct environment.

    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.

  13. added a commit that references this issue on Nov 16, 2019
    eee1fce
  14. added a commit that references this issue on Nov 17, 2019
    bf9012b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛dhcpnetwork

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions