summaryrefslogtreecommitdiffstats
path: root/nixos/tests/ulogd/ulogd.nix
blob: 2130a334fea16ce8a39d73e6070d2414218f28f2 (plain)
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
{ 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;
}