summaryrefslogtreecommitdiff
path: root/hosts/surtr/ruleset.nft
blob: b72169483da6c14a2b3415922c2f3b22a0b548e8 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
define icmp_protos = {ipv6-icmp, icmp, igmp}

table arp filter {
  limit lim_arp {
    rate over 50 mbytes/second burst 50 mbytes
  }

  chain input {
    type filter hook input priority filter
    policy accept

    limit name lim_arp counter drop

    counter
  }

  chain output {
    type filter hook output priority filter
    policy accept

    limit name lim_arp counter drop

    counter
  }
}

table inet filter {
  limit lim_reject {
    rate over 1000/second burst 1000 packets
  }

  limit lim_icmp {
    rate over 50 mbytes/second burst 50 mbytes
  }


  chain forward {
    type filter hook forward priority filter
    policy drop


    ct state invalid log level debug prefix "drop invalid forward: " counter drop


    iifname lo counter accept

    meta l4proto $icmp_protos iifname {yggdrasil, bifrost} oifname {bifrost, ens3} limit name lim_icmp counter drop
    meta l4proto $icmp_protos iifname {yggdrasil, bifrost} oifname {bifrost, ens3} counter accept
    meta l4proto $icmp_protos ct state {established, related} limit name lim_icmp counter drop
    meta l4proto $icmp_protos ct state {established, related} counter accept
    meta l4proto $icmp_protos oifname bifrost limit name lim_icmp counter drop
    meta l4proto $icmp_protos oifname bifrost counter accept


    oifname bifrost counter accept
    iifname bifrost oifname ens3 counter accept


    limit name lim_reject log level debug prefix "drop forward: " counter drop
    log level debug prefix "reject forward: " counter
    meta l4proto tcp ct state new counter reject with tcp reset
    ct state new counter reject


    counter
  }

  chain input {
    type filter hook input priority filter
    policy drop


    ct state invalid log level debug prefix "drop invalid input: " counter drop
    

    iifname lo counter accept
    iif != lo ip daddr 127.0.0.1/8 counter reject
    iif != lo ip6 daddr ::1/128 counter reject

    meta l4proto $icmp_protos limit name lim_icmp counter drop
    meta l4proto $icmp_protos counter accept

    tcp dport 22 counter accept
    udp dport 60001-61000 counter accept

    meta protocol ip udp dport 51820 counter accept
    meta protocol ip6 udp dport {51821, 51822} counter accept
    iifname "yggdrasil-wg-*" meta l4proto gre counter accept

    tcp dport 53 counter accept
    udp dport 53 counter accept

    tcp dport {80, 443, 8448} counter accept

    tcp dport {3478, 5349} counter accept
    udp dport {3478, 5349} counter accept
    udp dport 49000-50000 counter accept

    ct state {established, related} counter accept


    limit name lim_reject log level debug prefix "drop input: " counter drop
    log level debug prefix "reject input: " counter
    meta l4proto tcp ct state new counter reject with tcp reset
    ct state new counter reject


    counter
  }

  chain output {
    type filter hook output priority filter
    policy accept


    oifname lo counter accept

    meta l4proto $icmp_protos limit name lim_icmp counter drop
    meta l4proto $icmp_protos counter accept


    counter
  }
}