at master 3.0 kB view raw
1{ 2 name = "corerad"; 3 nodes = { 4 router = { 5 # This machine simulates a router with IPv6 forwarding and a static IPv6 address. 6 boot.kernel.sysctl = { 7 "net.ipv6.conf.all.forwarding" = true; 8 }; 9 networking.interfaces.eth1 = { 10 ipv6.addresses = [ 11 { 12 address = "fd00:dead:beef:dead::1"; 13 prefixLength = 64; 14 } 15 ]; 16 }; 17 services.corerad = { 18 enable = true; 19 # Serve router advertisements to the client machine with prefix information matching 20 # any IPv6 /64 prefixes configured on this interface. 21 # 22 # This configuration is identical to the example in the CoreRAD NixOS module. 23 settings = { 24 interfaces = [ 25 { 26 name = "eth0"; 27 monitor = true; 28 } 29 { 30 name = "eth1"; 31 advertise = true; 32 prefix = [ { prefix = "::/64"; } ]; 33 } 34 ]; 35 debug = { 36 address = "localhost:9430"; 37 prometheus = true; 38 }; 39 }; 40 }; 41 }; 42 client = 43 { pkgs, ... }: 44 { 45 # Use IPv6 SLAAC from router advertisements, and install rdisc6 so we can 46 # trigger one immediately. 47 boot.kernel.sysctl = { 48 "net.ipv6.conf.all.autoconf" = true; 49 }; 50 environment.systemPackages = with pkgs; [ 51 ndisc6 52 ]; 53 }; 54 }; 55 56 testScript = '' 57 start_all() 58 59 with subtest("Wait for CoreRAD and network ready"): 60 # Ensure networking is online and CoreRAD is ready. 61 router.systemctl("start network-online.target") 62 client.systemctl("start network-online.target") 63 router.wait_for_unit("network-online.target") 64 client.wait_for_unit("network-online.target") 65 router.wait_for_unit("corerad.service") 66 67 # Ensure the client can reach the router. 68 client.wait_until_succeeds("ping -c 1 fd00:dead:beef:dead::1") 69 70 with subtest("Verify SLAAC on client"): 71 # Trigger a router solicitation and verify a SLAAC address is assigned from 72 # the prefix configured on the router. 73 client.wait_until_succeeds("rdisc6 -1 -r 10 eth1") 74 client.wait_until_succeeds( 75 "ip -6 addr show dev eth1 | grep -q 'fd00:dead:beef:dead:'" 76 ) 77 78 addrs = client.succeed("ip -6 addr show dev eth1") 79 80 assert ( 81 "fd00:dead:beef:dead:" in addrs 82 ), "SLAAC prefix was not found in client addresses after router advertisement" 83 assert ( 84 "/64 scope global temporary" in addrs 85 ), "SLAAC temporary address was not configured on client after router advertisement" 86 87 with subtest("Verify HTTP debug server is configured"): 88 out = router.succeed("curl -f localhost:9430/metrics") 89 90 assert ( 91 "corerad_build_info" in out 92 ), "Build info metric was not found in Prometheus output" 93 ''; 94}