nixos/network-interfaces: make preferTempAddr=false
work again
This commit is contained in:
parent
ab225fc1ab
commit
1738283e6e
@ -1089,12 +1089,22 @@ in
|
|||||||
|
|
||||||
services.udev.packages = [
|
services.udev.packages = [
|
||||||
(pkgs.writeTextFile rec {
|
(pkgs.writeTextFile rec {
|
||||||
name = "99-ipv6-privacy-extensions.rules";
|
name = "ipv6-privacy-extensions.rules";
|
||||||
destination = "/etc/udev/rules.d/99-${name}";
|
destination = "/etc/udev/rules.d/98-${name}";
|
||||||
text = ''
|
text = ''
|
||||||
|
# enable and prefer IPv6 privacy addresses by default
|
||||||
ACTION=="add", SUBSYSTEM=="net", RUN+="${pkgs.procps}/bin/sysctl net.ipv6.conf.%k.use_tempaddr=2"
|
ACTION=="add", SUBSYSTEM=="net", RUN+="${pkgs.procps}/bin/sysctl net.ipv6.conf.%k.use_tempaddr=2"
|
||||||
'';
|
'';
|
||||||
}) ] ++ lib.optional (cfg.wlanInterfaces != {})
|
})
|
||||||
|
(pkgs.writeTextFile rec {
|
||||||
|
name = "ipv6-privacy-extensions.rules";
|
||||||
|
destination = "/etc/udev/rules.d/99-${name}";
|
||||||
|
text = concatMapStrings (i: ''
|
||||||
|
# enable IPv6 privacy addresses but prefer EUI-64 addresses for ${i.name}
|
||||||
|
ACTION=="add", SUBSYSTEM=="net", RUN+="${pkgs.procps}/bin/sysctl net.ipv6.conf.${i.name}.use_tempaddr=1"
|
||||||
|
'') (filter (i: !i.preferTempAddress) interfaces);
|
||||||
|
})
|
||||||
|
] ++ lib.optional (cfg.wlanInterfaces != {})
|
||||||
(pkgs.writeTextFile {
|
(pkgs.writeTextFile {
|
||||||
name = "99-zzz-40-wlanInterfaces.rules";
|
name = "99-zzz-40-wlanInterfaces.rules";
|
||||||
destination = "/etc/udev/rules.d/99-zzz-40-wlanInterfaces.rules";
|
destination = "/etc/udev/rules.d/99-zzz-40-wlanInterfaces.rules";
|
||||||
|
@ -510,7 +510,7 @@ let
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
nodes.client = { pkgs, ... }: with pkgs.lib; {
|
nodes.clientWithPrivacy = { pkgs, ... }: with pkgs.lib; {
|
||||||
virtualisation.vlans = [ 1 ];
|
virtualisation.vlans = [ 1 ];
|
||||||
networking = {
|
networking = {
|
||||||
useNetworkd = networkd;
|
useNetworkd = networkd;
|
||||||
@ -522,21 +522,39 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
nodes.client = { pkgs, ... }: with pkgs.lib; {
|
||||||
|
virtualisation.vlans = [ 1 ];
|
||||||
|
networking = {
|
||||||
|
useNetworkd = networkd;
|
||||||
|
useDHCP = true;
|
||||||
|
interfaces.eth1 = {
|
||||||
|
preferTempAddress = false;
|
||||||
|
ipv4.addresses = mkOverride 0 [ ];
|
||||||
|
ipv6.addresses = mkOverride 0 [ ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
testScript = { ... }:
|
testScript = { ... }:
|
||||||
''
|
''
|
||||||
startAll;
|
startAll;
|
||||||
|
|
||||||
$client->waitForUnit("network.target");
|
$client->waitForUnit("network.target");
|
||||||
|
$clientWithPrivacy->waitForUnit("network.target");
|
||||||
$router->waitForUnit("network-online.target");
|
$router->waitForUnit("network-online.target");
|
||||||
|
|
||||||
# Wait until we have an ip address
|
# Wait until we have an ip address
|
||||||
|
$clientWithPrivacy->waitUntilSucceeds("ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'");
|
||||||
$client->waitUntilSucceeds("ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'");
|
$client->waitUntilSucceeds("ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'");
|
||||||
|
|
||||||
# Test vlan 1
|
# Test vlan 1
|
||||||
|
$clientWithPrivacy->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::1");
|
||||||
$client->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::1");
|
$client->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::1");
|
||||||
|
|
||||||
# Test address used is temporary
|
# Test address used is temporary
|
||||||
$client->waitUntilSucceeds("! ip route get fd00:1234:5678:1::1 | grep -q ':[a-f0-9]*ff:fe[a-f0-9]*:'");
|
$clientWithPrivacy->waitUntilSucceeds("! ip route get fd00:1234:5678:1::1 | grep -q ':[a-f0-9]*ff:fe[a-f0-9]*:'");
|
||||||
|
|
||||||
|
# Test address used is EUI-64
|
||||||
|
$client->waitUntilSucceeds("ip route get fd00:1234:5678:1::1 | grep -q ':[a-f0-9]*ff:fe[a-f0-9]*:'");
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
routes = {
|
routes = {
|
||||||
|
Loading…
Reference in New Issue
Block a user