diff --git a/lan.nix b/lan.nix index 0456011..cb84582 100644 --- a/lan.nix +++ b/lan.nix @@ -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} + ''; }; }; } diff --git a/module.nix b/module.nix index 8a5393a..a12d267 100644 --- a/module.nix +++ b/module.nix @@ -6,7 +6,6 @@ ./hostapd.nix ./lan.nix ./options.nix - ./ra.nix ./wan.nix ]; diff --git a/options.nix b/options.nix index 817f74c..f472df6 100644 --- a/options.nix +++ b/options.nix @@ -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; { @@ -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"; @@ -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 [ diff --git a/ra.nix b/ra.nix deleted file mode 100644 index 78936cb..0000000 --- a/ra.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ config, lib, ... }: -{ - config = lib.mkIf config.router.enable { - services.corerad = { - enable = true; - settings = { - debug = { - address = ":9430"; - prometheus = true; - }; - interfaces = - (lib.optional config.router.wanSupportsDHCPv6 { - name = config.systemd.network.networks."10-wan".name; - monitor = true; - }) - ++ [ - { - name = config.systemd.network.networks."10-lan".name; - advertise = true; - managed = false; - other_config = false; - - # Advertise all /64 prefixes on the interface. - prefix = [ { } ]; - - # Automatically use the appropriate interface address as a DNS - # server. - rdnss = [ { } ]; - - # Setup IPv6-only on internal network by advertising NAT64 prefix to - # clients. - pref64 = [ { prefix = config.networking.jool.nat64.default.global.pool6; } ]; - } - ]; - }; - }; - }; -} diff --git a/test.nix b/test.nix index 8d10f02..8396cd8 100644 --- a/test.nix +++ b/test.nix @@ -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.") ''; }