Skip to content

Commit 386411e

Browse files
committed
Use builtin IPv6 RA support in systemd-networkd
1 parent dcb0209 commit 386411e

File tree

5 files changed

+32
-94
lines changed

5 files changed

+32
-94
lines changed

lan.nix

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,32 @@ in
1313
networkConfig = {
1414
DHCPPrefixDelegation = true;
1515
IPv6AcceptRA = false;
16+
IPv6SendRA = true;
1617
IgnoreCarrierLoss = true;
1718
MulticastDNS = true;
18-
Address = [
19-
cfg.routerIpv6Ula.cidr
20-
] ++ lib.optional (cfg.ipv6GuaPrefix != null) cfg.routerIpv6Gua.cidr;
2119
};
20+
ipv6SendRAConfig = {
21+
EmitDNS = true;
22+
DNS = "_link_local";
23+
};
24+
ipv6Prefixes =
25+
[
26+
{
27+
Prefix = cfg.ipv6UlaPrefix;
28+
Assign = true;
29+
}
30+
]
31+
++ lib.optionals (cfg.ipv6GuaPrefix != null) [
32+
{
33+
Prefix = cfg.ipv6GuaPrefix;
34+
Assign = true;
35+
}
36+
];
37+
# TODO(jared): make nixos option
38+
extraConfig = ''
39+
[IPv6PREF64Prefix]
40+
Prefix=${config.networking.jool.nat64.default.global.pool6}
41+
'';
2242
};
2343
};
2444
}

module.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
./hostapd.nix
77
./lan.nix
88
./options.nix
9-
./ra.nix
109
./wan.nix
1110
];
1211

options.nix

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ let
77
hasStaticGua = cfg.ipv6GuaPrefix != null;
88
guaNetwork = _lib.parseIpv6Network cfg.ipv6GuaPrefix;
99
ulaNetwork = _lib.parseIpv6Network cfg.ipv6UlaPrefix;
10-
11-
mkIpv6GuaAddress = _lib.mkIpv6Address guaNetwork.hextets;
12-
mkIpv6UlaAddress = _lib.mkIpv6Address ulaNetwork.hextets;
1310
in
1411
{
1512
options.router = with lib; {
@@ -88,30 +85,6 @@ in
8885
The 64-bit IPv6 GUA network prefix (in CIDR notation).
8986
'';
9087
};
91-
routerIpv6Gua = mkOption {
92-
internal = true;
93-
readOnly = true;
94-
default =
95-
let
96-
address = mkIpv6GuaAddress [
97-
0
98-
0
99-
0
100-
0
101-
0
102-
0
103-
0
104-
1
105-
];
106-
in
107-
if hasStaticGua then
108-
{
109-
inherit address;
110-
cidr = "${address}/${toString guaNetwork.prefixLength}";
111-
}
112-
else
113-
null;
114-
};
11588
ipv6UlaPrefix = mkOption {
11689
type = types.str;
11790
example = "fd38:5f81:b15d::/64";
@@ -120,27 +93,6 @@ in
12093
a ULA prefix at https://www.ip-six.de/index.php.
12194
'';
12295
};
123-
routerIpv6Ula = mkOption {
124-
internal = true;
125-
readOnly = true;
126-
default =
127-
let
128-
address = mkIpv6UlaAddress [
129-
0
130-
0
131-
0
132-
0
133-
0
134-
0
135-
0
136-
1
137-
];
138-
in
139-
{
140-
inherit address;
141-
cidr = "${address}/${toString ulaNetwork.prefixLength}";
142-
};
143-
};
14496
dns = {
14597
upstreamProvider = mkOption {
14698
type = types.enum [

ra.nix

Lines changed: 0 additions & 38 deletions
This file was deleted.

test.nix

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@ nixosTest {
3737
};
3838

3939
testScript = ''
40-
router.wait_for_unit("systemd-networkd.service")
41-
host1.wait_for_unit("multi-user.target")
40+
router.wait_for_unit("network-online.target")
41+
host1.wait_for_unit("network-online.target")
4242
43-
router.wait_until_succeeds("ping -c5 host1.local.")
44-
host1.wait_until_succeeds("ping -c5 router.local.")
43+
print(router.succeed("networkctl status eth1"))
44+
print(router.succeed("resolvectl"))
45+
print(host1.succeed("networkctl status eth1"))
46+
print(host1.succeed("resolvectl"))
47+
48+
router.wait_until_succeeds("ping -c3 host1.local.")
49+
host1.wait_until_succeeds("ping -c3 router.local.")
4550
'';
4651
}

0 commit comments

Comments
 (0)