diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index d24f7c923ce..0c1180af645 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -115,6 +115,15 @@ in ''; }; + macAddress = mkOption { + default = ""; + example = "00:11:22:33:44:55"; + type = types.string; + description = '' + MAC address of the interface. Leave empty to use the default. + ''; + }; + }; }; @@ -157,6 +166,16 @@ in export PATH=${config.system.sbin.modprobe}/sbin:$PATH modprobe af_packet || true + ${pkgs.lib.concatMapStrings (i: + if i.macAddress != "" then + '' + echo "Configuring interface ${i.name}..." + ${ifconfig} "${i.name}" down || true + ${ifconfig} hw ether "${i.name}" "${i.macAddress}" || true + '' + else "") cfg.interfaces + } + for i in $(cd /sys/class/net && ls -d *); do echo "Bringing up network device $i..." ${ifconfig} $i up || true