1 import ./make-test-python.nix (
5 router = {config, pkgs, ...}: {
7 # This machine simulates a router with IPv6 forwarding and a static IPv6 address.
9 "net.ipv6.conf.all.forwarding" = true;
11 networking.interfaces.eth1 = {
12 ipv6.addresses = [ { address = "fd00:dead:beef:dead::1"; prefixLength = 64; } ];
16 # Serve router advertisements to the client machine with prefix information matching
17 # any IPv6 /64 prefixes configured on this interface.
19 # This configuration is identical to the example in the CoreRAD NixOS module.
29 prefix = [{ prefix = "::/64"; }];
33 address = "localhost:9430";
40 client = {config, pkgs, ...}: {
41 # Use IPv6 SLAAC from router advertisements, and install rdisc6 so we can
42 # trigger one immediately.
44 boot.kernel.sysctl = {
45 "net.ipv6.conf.all.autoconf" = true;
47 environment.systemPackages = with pkgs; [
57 with subtest("Wait for CoreRAD and network ready"):
58 # Ensure networking is online and CoreRAD is ready.
59 router.wait_for_unit("network-online.target")
60 client.wait_for_unit("network-online.target")
61 router.wait_for_unit("corerad.service")
63 # Ensure the client can reach the router.
64 client.wait_until_succeeds("ping -c 1 fd00:dead:beef:dead::1")
66 with subtest("Verify SLAAC on client"):
67 # Trigger a router solicitation and verify a SLAAC address is assigned from
68 # the prefix configured on the router.
69 client.wait_until_succeeds("rdisc6 -1 -r 10 eth1")
70 client.wait_until_succeeds(
71 "ip -6 addr show dev eth1 | grep -q 'fd00:dead:beef:dead:'"
74 addrs = client.succeed("ip -6 addr show dev eth1")
77 "fd00:dead:beef:dead:" in addrs
78 ), "SLAAC prefix was not found in client addresses after router advertisement"
80 "/64 scope global temporary" in addrs
81 ), "SLAAC temporary address was not configured on client after router advertisement"
83 with subtest("Verify HTTP debug server is configured"):
84 out = router.succeed("curl -f localhost:9430/metrics")
87 "corerad_build_info" in out
88 ), "Build info metric was not found in Prometheus output"