summary refs log tree commit diff
path: root/nixos/tests/ndppd.nix
blob: b67b26a79341f62bff163d75f8a25b911f1fd338 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import ./make-test-python.nix ({ pkgs, lib, ...} : {
  name = "ndppd";
  meta = with pkgs.stdenv.lib.maintainers; {
    maintainers = [ fpletz ];
  };

  nodes = {
    upstream = { pkgs, ... }: {
      environment.systemPackages = [ pkgs.tcpdump ];
      networking.useDHCP = false;
      networking.interfaces = {
        eth1 = {
          ipv6.addresses = [
            { address = "fd23::1"; prefixLength = 112; }
          ];
          ipv6.routes = [
            { address = "fd42::";
              prefixLength = 112;
            }
          ];
        };
      };
    };
    server = { pkgs, ... }: {
      boot.kernel.sysctl = {
        "net.ipv6.conf.all.forwarding" = "1";
        "net.ipv6.conf.default.forwarding" = "1";
      };
      environment.systemPackages = [ pkgs.tcpdump ];
      networking.useDHCP = false;
      networking.interfaces = {
        eth1 = {
          ipv6.addresses = [
            { address = "fd23::2"; prefixLength = 112; }
          ];
        };
      };
      services.ndppd = {
        enable = true;
        proxies.eth1.rules."fd42::/112" = {};
      };
      containers.client = {
        autoStart = true;
        privateNetwork = true;
        hostAddress = "192.168.255.1";
        localAddress = "192.168.255.2";
        hostAddress6 = "fd42::1";
        localAddress6 = "fd42::2";
        config = {};
      };
    };
  };

  testScript = ''
    start_all()
    server.wait_for_unit("multi-user.target")
    upstream.wait_for_unit("multi-user.target")
    upstream.wait_until_succeeds("ping -c5 fd42::2")
  '';
})