network-interfaces: support changing MAC addresses of interfaces
svn path=/nixos/trunk/; revision=24846
This commit is contained in:
parent
50d8698fd8
commit
72422d4126
@ -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
|
export PATH=${config.system.sbin.modprobe}/sbin:$PATH
|
||||||
modprobe af_packet || true
|
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
|
for i in $(cd /sys/class/net && ls -d *); do
|
||||||
echo "Bringing up network device $i..."
|
echo "Bringing up network device $i..."
|
||||||
${ifconfig} $i up || true
|
${ifconfig} $i up || true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user