I'm suddenly getting a random MAC address after reboot

Hi everybody,

Something changed in NixOS 23.11 default config…

Today I updated my PC that runs stable NixOS 23.11 and that hasn’t been updated for approx ~3 weeks. After rebooting, I realized that the network was down. After some investigation I realized that USB NIC adapter ax88179_178a has a different MAC address and therefore static IP is not set (I set static IP to specific interfaces using systemd-network).

I thought that is strange and I updated my second PC which also had outdated NixOS and also has the same model of USB adapter and again, the MAC changed after reboot.

I didn’t change my configuration so I assume something changed in NixOS default configuration and I’m now getting random MACs on each reboot. Or maybe kernel is built with different options.

I don’t know how to fix it… My only hope was that Network Manager is doing something funny but I checked and those interfaces are unmanaged and I also tried and removed Network Manager and it didn’t help…

Any suggestions?

Thank you.

Are you sure you removed Network Manager and not just stop it (systemctl stop NetworkManager.service)?

You might look into /etc/NetworkManager/NetworkManager.conf for:

[connection]
ethernet.cloned-mac-address=<value>

I think the default is preserve and you might need to change it to permanent.

To change it there will be an option in config.networking.networkmanager.

2 Likes

Thank you. For wired NICs I use systemd-network and after reading your post I completely removed Network Manager and it still doesn’t work (the mac address changes every reboot).

My assumption is that something changed in the last kernel update or in systemd-network but I can’t figure out what.

And all other laptops / PCs are OK - the only problem is those with ax88179_178a

And it’s weird that something changed since I’m on stable 23.11.

I use networkd for my bonded connection and also get random MAC recently.

I can’t find a solution - did you?

The bond MAC is generated based on the interface name and machine ID but you should be also able to specify it.

Could you share your NixOS config (just the bond / network part)?

My networking code is below…

{
  systemd.services.systemd-networkd-wait-online.serviceConfig.ExecStart = [
    "" # clear old command
    "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --ignore enp7s0 --ignore enp8s0"
  ];

  networking = {
    hostId = "hostid";
    hostName = "hostname";
#    networkmanager.enable = true;
    useDHCP = false;
    useNetworkd = true;
  };

  systemd.network = {
    enable = true;

    netdevs = {
      "10-bond0" = {
        netdevConfig = {
          Kind = "bond";
          Name = "bond0";
        };
        bondConfig = {
          Mode = "802.3ad";
          LACPTransmitRate= "fast";
          MIIMonitorSec= "100";
          TransmitHashPolicy = "layer3+4";
        };
      };
    };

    networks = {
      "30-enp7s0" = {
        matchConfig.Name = "enp7s0";
        linkConfig.RequiredForOnline = "no";
        networkConfig = {
          Bond = "bond0";
          DHCP = "no";
        };
      };
      "30-enp8s0" = {
        matchConfig.Name = "enp8s0";
        linkConfig.RequiredForOnline = "no";
        networkConfig = {
          Bond = "bond0";
          DHCP = "no";
        };
      };

      "40-bond0" = {
        matchConfig.Name = "bond0";
        DHCP = "yes";
        linkConfig.RequiredForOnline = "routable";

        dhcpV4Config = {
          UseDNS = true;
          UseNTP = true;
        };

        dhcpV6Config = {
#          UseDNS = true;
#          UseNTP = true;
        };

        ipv6AcceptRAConfig = {
          DHCPv6Client = "always";
#          useDNS = true;
        };

        networkConfig = {
          IPv6AcceptRA = true;
          LinkLocalAddressing = "no";
          DHCP = lib.mkDefault "ipv4";
        };

      };
    };
    wait-online.timeout = 60;
  };
}

Not a suggestion: I think I need to replicate your situation because that may probably allow me to circumvent the undocumented lack of a setting in the Linux distro I have on my non-NixOS machine mainly because I can’t change it (see https://www.reddit.com/r/AllExceptNeeded/s/vONJktmxky)

UPD: The issue was different