Skip to content

Commit

Permalink
Use builtin IPv6 RA support in systemd-networkd
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbaur committed Jun 8, 2024
1 parent dcb0209 commit 386411e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 94 deletions.
26 changes: 23 additions & 3 deletions lan.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,32 @@ in
networkConfig = {
DHCPPrefixDelegation = true;
IPv6AcceptRA = false;
IPv6SendRA = true;
IgnoreCarrierLoss = true;
MulticastDNS = true;
Address = [
cfg.routerIpv6Ula.cidr
] ++ lib.optional (cfg.ipv6GuaPrefix != null) cfg.routerIpv6Gua.cidr;
};
ipv6SendRAConfig = {
EmitDNS = true;
DNS = "_link_local";
};
ipv6Prefixes =
[
{
Prefix = cfg.ipv6UlaPrefix;
Assign = true;
}
]
++ lib.optionals (cfg.ipv6GuaPrefix != null) [
{
Prefix = cfg.ipv6GuaPrefix;
Assign = true;
}
];
# TODO(jared): make nixos option
extraConfig = ''
[IPv6PREF64Prefix]
Prefix=${config.networking.jool.nat64.default.global.pool6}
'';
};
};
}
1 change: 0 additions & 1 deletion module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
./hostapd.nix
./lan.nix
./options.nix
./ra.nix
./wan.nix
];

Expand Down
48 changes: 0 additions & 48 deletions options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ let
hasStaticGua = cfg.ipv6GuaPrefix != null;
guaNetwork = _lib.parseIpv6Network cfg.ipv6GuaPrefix;
ulaNetwork = _lib.parseIpv6Network cfg.ipv6UlaPrefix;

mkIpv6GuaAddress = _lib.mkIpv6Address guaNetwork.hextets;
mkIpv6UlaAddress = _lib.mkIpv6Address ulaNetwork.hextets;
in
{
options.router = with lib; {
Expand Down Expand Up @@ -88,30 +85,6 @@ in
The 64-bit IPv6 GUA network prefix (in CIDR notation).
'';
};
routerIpv6Gua = mkOption {
internal = true;
readOnly = true;
default =
let
address = mkIpv6GuaAddress [
0
0
0
0
0
0
0
1
];
in
if hasStaticGua then
{
inherit address;
cidr = "${address}/${toString guaNetwork.prefixLength}";
}
else
null;
};
ipv6UlaPrefix = mkOption {
type = types.str;
example = "fd38:5f81:b15d::/64";
Expand All @@ -120,27 +93,6 @@ in
a ULA prefix at https://www.ip-six.de/index.php.
'';
};
routerIpv6Ula = mkOption {
internal = true;
readOnly = true;
default =
let
address = mkIpv6UlaAddress [
0
0
0
0
0
0
0
1
];
in
{
inherit address;
cidr = "${address}/${toString ulaNetwork.prefixLength}";
};
};
dns = {
upstreamProvider = mkOption {
type = types.enum [
Expand Down
38 changes: 0 additions & 38 deletions ra.nix

This file was deleted.

13 changes: 9 additions & 4 deletions test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ nixosTest {
};

testScript = ''
router.wait_for_unit("systemd-networkd.service")
host1.wait_for_unit("multi-user.target")
router.wait_for_unit("network-online.target")
host1.wait_for_unit("network-online.target")
router.wait_until_succeeds("ping -c5 host1.local.")
host1.wait_until_succeeds("ping -c5 router.local.")
print(router.succeed("networkctl status eth1"))
print(router.succeed("resolvectl"))
print(host1.succeed("networkctl status eth1"))
print(host1.succeed("resolvectl"))
router.wait_until_succeeds("ping -c3 host1.local.")
host1.wait_until_succeeds("ping -c3 router.local.")
'';
}

0 comments on commit 386411e

Please sign in to comment.