about summary refs log tree commit diff
path: root/nixos/tests/ulogd/ulogd.nix
blob: 0fa92229a10054e7115ad2b8316be6bc0d4d28c0 (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
import ../make-test-python.nix ({ pkgs, lib, ... }: {
  name = "ulogd";

  meta.maintainers = with lib.maintainers; [ p-h ];

  nodes.machine = { ... }: {
    networking.firewall.enable = false;
    networking.nftables.enable = true;
    networking.nftables.ruleset = ''
      table inet filter {
        chain input {
          type filter hook input priority 0;
          icmp type { echo-request, echo-reply } log group 2 accept
        }

        chain output {
          type filter hook output priority 0; policy accept;
          icmp type { echo-request, echo-reply } log group 2 accept
        }

        chain forward {
          type filter hook forward priority 0; policy drop;
        }

      }
    '';
    services.ulogd = {
      enable = true;
      settings = {
        global = {
          logfile = "/var/log/ulogd.log";
          stack = [
            "log1:NFLOG,base1:BASE,ifi1:IFINDEX,ip2str1:IP2STR,print1:PRINTPKT,emu1:LOGEMU"
            "log1:NFLOG,base1:BASE,pcap1:PCAP"
          ];
        };

        log1.group = 2;

        pcap1 = {
          sync = 1;
          file = "/var/log/ulogd.pcap";
        };

        emu1 = {
          sync = 1;
          file = "/var/log/ulogd_pkts.log";
        };
      };
    };

    environment.systemPackages = with pkgs; [ tcpdump ];
  };

  testScript = lib.readFile ./ulogd.py;
})