Debian Codegraph @

test/70-rate/golden.txt

raw
1 table inet foomuuri
2 delete table inet foomuuri
3
4 table inet foomuuri {
5
6 chain allow_icmp_4 {
7 icmp type {
8 destination-unreachable, # 3, Destination Unreachable
9 time-exceeded, # 11, Time Exceeded
10 parameter-problem # 12, Parameter Problem
11 } accept
12 }
13
14 chain allow_icmp_6 {
15 icmpv6 type {
16 destination-unreachable, # 1, Destination Unreachable
17 packet-too-big, # 2, Packet Too Big
18 time-exceeded, # 3, Time Exceeded
19 parameter-problem, # 4, Parameter Problem
20 nd-router-solicit, # 133, Router Solicitation
21 nd-neighbor-solicit, # 135, Neighbor Solicitation
22 nd-neighbor-advert, # 136, Neighbor Advertisement
23 ind-neighbor-solicit, # 141, Inverse Neighbor Discovery Solicitation Message
24 ind-neighbor-advert # 142, Inverse Neighbor Discovery Advertisement Message
25 } accept
26 icmpv6 type . ip6 saddr {
27 nd-router-advert . fe80::/10, # 134, Router Advertisement
28 mld-listener-query . fe80::/10, # 130, Multicast Listener Query
29 mld-listener-report . fe80::/10, # 131, Multicast Listener Report
30 mld-listener-done . fe80::/10, # 132, Multicast Listener Done
31 149 . fe80::/10, # 149, Certification Path Advertisement Message
32 151 . fe80::/10, # 151, Multicast Router Advertisement
33 152 . fe80::/10, # 152, Multicast Router Solicitation
34 153 . fe80::/10, # 153, Multicast Router Termination
35 mld2-listener-report . fe80::/10, # 143, Version 2 Multicast Listener Report
36 mld2-listener-report . ::,
37 148 . fe80::/10, # 148, Certification Path Solicitation Message
38 148 . ::
39 } accept
40 }
41
42 chain smurfs_4 {
43 ip saddr 0.0.0.0 return
44 fib saddr type { broadcast, multicast } jump smurfs_drop
45 }
46
47 chain smurfs_6 {
48 fib saddr type multicast jump smurfs_drop
49 }
50
51 chain invalid_drop {
52 drop
53 }
54
55 chain smurfs_drop {
56 drop
57 }
58
59 chain rpfilter_drop {
60 udp sport 67 udp dport 68 return
61 update @_lograte_set_4 { ip saddr limit rate 1/second burst 3 packets } log prefix "RPFILTER DROP " level info flags skuid
62 update @_lograte_set_6 { ip6 saddr limit rate 1/second burst 3 packets } log prefix "RPFILTER DROP " level info flags skuid
63 drop
64 }
65
66 chain input {
67 type filter hook input priority filter + 5
68 iifname vmap @input_zones
69 update @_lograte_set_4 { ip saddr limit rate 1/second burst 3 packets } log prefix "INPUT DROP " level info flags skuid
70 update @_lograte_set_6 { ip6 saddr limit rate 1/second burst 3 packets } log prefix "INPUT DROP " level info flags skuid
71 drop
72 }
73
74 chain output {
75 type filter hook output priority filter + 5
76 oifname vmap @output_zones
77 ip protocol igmp ip daddr 224.0.0.22 accept
78 ip6 saddr :: icmpv6 type mld2-listener-report accept
79 update @_lograte_set_4 { ip saddr limit rate 1/second burst 3 packets } log prefix "OUTPUT REJECT " level info flags skuid
80 update @_lograte_set_6 { ip6 saddr limit rate 1/second burst 3 packets } log prefix "OUTPUT REJECT " level info flags skuid
81 reject with icmpx admin-prohibited
82 }
83
84 chain forward {
85 type filter hook forward priority filter + 5
86 iifname . oifname vmap @forward_zones
87 update @_lograte_set_4 { ip saddr limit rate 1/second burst 3 packets } log prefix "FORWARD DROP " level info flags skuid
88 update @_lograte_set_6 { ip6 saddr limit rate 1/second burst 3 packets } log prefix "FORWARD DROP " level info flags skuid
89 drop
90 }
91
92 set _rate_set_1_4 {
93 type ipv4_addr
94 size 65535
95 flags dynamic,timeout
96 timeout 1m
97 }
98
99 set _rate_set_1_6 {
100 type ipv6_addr
101 size 65535
102 flags dynamic,timeout
103 timeout 1m
104 }
105
106 set _rate_set_2_4 {
107 type ipv4_addr
108 size 65535
109 flags dynamic,timeout
110 timeout 1h
111 gc-interval 5m
112 }
113
114 set _rate_set_2_6 {
115 type ipv6_addr
116 size 65535
117 flags dynamic,timeout
118 timeout 1h
119 gc-interval 5m
120 }
121
122 map input_zones {
123 type ifname : verdict
124 elements = {
125 "lo" : accept,
126 }
127 }
128
129 map output_zones {
130 type ifname : verdict
131 elements = {
132 "lo" : accept,
133 }
134 }
135
136 map forward_zones {
137 type ifname . ifname : verdict
138 elements = {
139 "lo" . "lo" : accept,
140 }
141 }
142
143 chain public-localhost {
144 meta nfproto vmap {
145 ipv4 : jump public-localhost_4,
146 ipv6 : jump public-localhost_6
147 }
148 }
149
150 chain public-localhost_4 {
151 jump allow_icmp_4
152 ct state vmap {
153 established : accept,
154 related : accept,
155 invalid : jump invalid_drop,
156 new : jump smurfs_4,
157 untracked : jump smurfs_4
158 }
159 ip protocol igmp ip daddr 224.0.0.1 accept
160 fib daddr type { broadcast, multicast } drop
161 limit rate 3/second accept
162 limit rate 4/minute burst 5 packets accept
163 limit rate 5/hour burst 6 packets accept
164 limit rate over 3/minute drop
165 limit rate 2 bytes/second accept
166 limit rate 3 kbytes/minute burst 4 mbytes accept
167 limit rate over 1 mbytes/second accept
168 limit rate over 6 kbytes/second burst 1 mbytes accept
169 ct count 4 accept
170 ct count over 5 accept
171 tcp dport 80 update @_rate_set_1_4 { ip saddr limit rate 5/minute burst 5 packets } accept
172 tcp dport 22 update @_rate_set_2_4 { ip saddr limit rate 20/hour burst 5 packets } accept
173 update @_lograte_set_4 { ip saddr limit rate 1/second burst 3 packets } log prefix "public-localhost DROP " level info flags skuid
174 drop
175 }
176
177 chain public-localhost_6 {
178 jump allow_icmp_6
179 ct state vmap {
180 established : accept,
181 related : accept,
182 invalid : jump invalid_drop,
183 new : jump smurfs_6,
184 untracked : jump smurfs_6
185 }
186 fib daddr type multicast drop
187 limit rate 3/second accept
188 limit rate 4/minute burst 5 packets accept
189 limit rate 5/hour burst 6 packets accept
190 limit rate over 3/minute drop
191 limit rate 2 bytes/second accept
192 limit rate 3 kbytes/minute burst 4 mbytes accept
193 limit rate over 1 mbytes/second accept
194 limit rate over 6 kbytes/second burst 1 mbytes accept
195 ct count 4 accept
196 ct count over 5 accept
197 tcp dport 80 update @_rate_set_1_6 { ip6 saddr limit rate 5/minute burst 5 packets } accept
198 tcp dport 22 update @_rate_set_2_6 { ip6 saddr limit rate 20/hour burst 5 packets } accept
199 update @_lograte_set_6 { ip6 saddr limit rate 1/second burst 3 packets } log prefix "public-localhost DROP " level info flags skuid
200 drop
201 }
202
203 chain localhost-localhost {
204 meta nfproto vmap {
205 ipv4 : jump localhost-localhost_4,
206 ipv6 : jump localhost-localhost_6
207 }
208 }
209
210 chain localhost-localhost_4 {
211 jump allow_icmp_4
212 ct state vmap {
213 established : accept,
214 related : accept,
215 invalid : jump invalid_drop,
216 new : jump smurfs_4,
217 untracked : jump smurfs_4
218 }
219 accept
220 }
221
222 chain localhost-localhost_6 {
223 jump allow_icmp_6
224 ct state vmap {
225 established : accept,
226 related : accept,
227 invalid : jump invalid_drop,
228 new : jump smurfs_6,
229 untracked : jump smurfs_6
230 }
231 accept
232 }
233
234 chain localhost-public {
235 meta nfproto vmap {
236 ipv4 : jump localhost-public_4,
237 ipv6 : jump localhost-public_6
238 }
239 }
240
241 chain localhost-public_4 {
242 jump allow_icmp_4
243 ct state vmap {
244 established : accept,
245 related : accept,
246 invalid : jump invalid_drop,
247 new : jump smurfs_4,
248 untracked : jump smurfs_4
249 }
250 ip protocol igmp ip daddr 224.0.0.22 accept
251 update @_lograte_set_4 { ip saddr limit rate 1/second burst 3 packets } log prefix "localhost-public REJECT " level info flags skuid
252 reject with icmpx admin-prohibited
253 }
254
255 chain localhost-public_6 {
256 jump allow_icmp_6
257 ct state vmap {
258 established : accept,
259 related : accept,
260 invalid : jump invalid_drop,
261 new : jump smurfs_6,
262 untracked : jump smurfs_6
263 }
264 update @_lograte_set_6 { ip6 saddr limit rate 1/second burst 3 packets } log prefix "localhost-public REJECT " level info flags skuid
265 reject with icmpx admin-prohibited
266 }
267
268 chain public-public {
269 meta nfproto vmap {
270 ipv4 : jump public-public_4,
271 ipv6 : jump public-public_6
272 }
273 }
274
275 chain public-public_4 {
276 jump allow_icmp_4
277 ct state vmap {
278 established : accept,
279 related : accept,
280 invalid : jump invalid_drop,
281 new : jump smurfs_4,
282 untracked : jump smurfs_4
283 }
284 fib daddr type { broadcast, multicast } drop
285 update @_lograte_set_4 { ip saddr limit rate 1/second burst 3 packets } log prefix "public-public DROP " level info flags skuid
286 drop
287 }
288
289 chain public-public_6 {
290 jump allow_icmp_6
291 ct state vmap {
292 established : accept,
293 related : accept,
294 invalid : jump invalid_drop,
295 new : jump smurfs_6,
296 untracked : jump smurfs_6
297 }
298 fib daddr type multicast drop
299 update @_lograte_set_6 { ip6 saddr limit rate 1/second burst 3 packets } log prefix "public-public DROP " level info flags skuid
300 drop
301 }
302
303 set _lograte_set_4 {
304 type ipv4_addr
305 size 65535
306 flags dynamic,timeout
307 timeout 1m
308 }
309
310 set _lograte_set_6 {
311 type ipv6_addr
312 size 65535
313 flags dynamic,timeout
314 timeout 1m
315 }
316
317 chain rpfilter {
318 type filter hook prerouting priority filter + 5
319 fib saddr . mark . iif oif 0 meta ipsec missing jump rpfilter_drop
320 }
321
322 }