summary refs log tree commit diff
path: root/nixos/modules/services/networking
diff options
context:
space:
mode:
authorTom <Tom.TSmeets@Gmail.com>2017-03-07 03:50:37 +0100
committerJoachim F <joachifm@users.noreply.github.com>2017-03-07 03:50:37 +0100
commit9a7bad2c178c6b4642ed50e7d10e69d03dc3e35b (patch)
tree57f88f4f9626d53f4f444fa7e5f03f0c99a337b1 /nixos/modules/services/networking
parent2d0991580c3f4bd5b875bb919f60e1b8ec54b8af (diff)
downloadnixlib-9a7bad2c178c6b4642ed50e7d10e69d03dc3e35b.tar
nixlib-9a7bad2c178c6b4642ed50e7d10e69d03dc3e35b.tar.gz
nixlib-9a7bad2c178c6b4642ed50e7d10e69d03dc3e35b.tar.bz2
nixlib-9a7bad2c178c6b4642ed50e7d10e69d03dc3e35b.tar.lz
nixlib-9a7bad2c178c6b4642ed50e7d10e69d03dc3e35b.tar.xz
nixlib-9a7bad2c178c6b4642ed50e7d10e69d03dc3e35b.tar.zst
nixlib-9a7bad2c178c6b4642ed50e7d10e69d03dc3e35b.zip
networkmanager service: support changing the mac-address (#23464)
Set `networking.networkmanager.wifi.macAddress` or `networking.networkmanager.ethernet.macAddress`
to one of these values to change your macAddress.

* "XX:XX:XX:XX:XX:XX": set the MAC address of the interface.
* "permanent": use the permanent MAC address of the device.
* "preserve": don’t change the MAC address of the device upon activation.
* "random": generate a randomized value upon each connect.
* "stable": generate a stable, hashed MAC address.

See https://blogs.gnome.org/thaller/2016/08/26/mac-address-spoofing-in-networkmanager-1-4-0/ for more information
Diffstat (limited to 'nixos/modules/services/networking')
-rw-r--r--nixos/modules/services/networking/networkmanager.nix19
1 files changed, 19 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/networkmanager.nix b/nixos/modules/services/networking/networkmanager.nix
index c11d4434c206..7255ffc5af4b 100644
--- a/nixos/modules/services/networking/networkmanager.nix
+++ b/nixos/modules/services/networking/networkmanager.nix
@@ -24,6 +24,8 @@ let
 
     [connection]
     ipv6.ip6-privacy=2
+    ethernet.cloned-mac-address=${cfg.ethernet.macAddress}
+    wifi.cloned-mac-address=${cfg.wifi.macAddress}
   '';
 
   /*
@@ -73,6 +75,19 @@ let
     "pre-down" = "pre-down.d/";
   };
 
+  macAddressOpt = mkOption {
+    type = types.either types.str (types.enum ["permanent" "preserve" "random" "stable"]);
+    default = "preserve";
+    example = "00:11:22:33:44:55";
+    description = ''
+      "XX:XX:XX:XX:XX:XX": MAC address of the interface.
+      <literal>permanent</literal>: use the permanent MAC address of the device.
+      <literal>preserve</literal>: don’t change the MAC address of the device upon activation.
+      <literal>random</literal>: generate a randomized value upon each connect.
+      <literal>stable</literal>: generate a stable, hashed MAC address.
+    '';
+  };
+
 in {
 
   ###### interface
@@ -140,6 +155,9 @@ in {
         '';
       };
 
+      ethernet.macAddress = macAddressOpt;
+      wifi.macAddress = macAddressOpt;
+
       dispatcherScripts = mkOption {
         type = types.listOf (types.submodule {
           options = {
@@ -229,6 +247,7 @@ in {
 
     systemd.services."network-manager" = {
       wantedBy = [ "network.target" ];
+      restartTriggers = [ configFile ];
 
       preStart = ''
         mkdir -m 700 -p /etc/NetworkManager/system-connections