diff options
author | Evgeny Egorochkin <phreedom.stdin@gmail.com> | 2010-11-24 22:58:48 +0000 |
---|---|---|
committer | Evgeny Egorochkin <phreedom.stdin@gmail.com> | 2010-11-24 22:58:48 +0000 |
commit | 72422d41262b4f48f5bf20fd58f1714292750a13 (patch) | |
tree | 6b840fc106f338365124116434c8e4bdb385d4d2 /modules/tasks/network-interfaces.nix | |
parent | 50d8698fd8fc89301db1cce56d73132da76772d7 (diff) | |
download | nixpkgs-72422d41262b4f48f5bf20fd58f1714292750a13.tar nixpkgs-72422d41262b4f48f5bf20fd58f1714292750a13.tar.gz nixpkgs-72422d41262b4f48f5bf20fd58f1714292750a13.tar.bz2 nixpkgs-72422d41262b4f48f5bf20fd58f1714292750a13.tar.lz nixpkgs-72422d41262b4f48f5bf20fd58f1714292750a13.tar.xz nixpkgs-72422d41262b4f48f5bf20fd58f1714292750a13.tar.zst nixpkgs-72422d41262b4f48f5bf20fd58f1714292750a13.zip |
network-interfaces: support changing MAC addresses of interfaces
svn path=/nixos/trunk/; revision=24846
Diffstat (limited to 'modules/tasks/network-interfaces.nix')
-rw-r--r-- | modules/tasks/network-interfaces.nix | 19 |
1 files changed, 19 insertions, 0 deletions
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 |