| 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 |
map input_zones { |
| 93 |
type ifname : verdict |
| 94 |
elements = { |
| 95 |
"lo" : accept, |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
map output_zones { |
| 100 |
type ifname : verdict |
| 101 |
elements = { |
| 102 |
"lo" : accept, |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
map forward_zones { |
| 107 |
type ifname . ifname : verdict |
| 108 |
elements = { |
| 109 |
"lo" . "lo" : accept, |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
chain localhost-public { |
| 114 |
meta nfproto vmap { |
| 115 |
ipv4 : jump localhost-public_4, |
| 116 |
ipv6 : jump localhost-public_6 |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
chain localhost-public_4 { |
| 121 |
update @_lograte_set_4 { ip saddr limit rate 1/second burst 3 packets } log prefix "outgoing " level info flags skuid |
| 122 |
update @_lograte_set_4 { ip saddr limit rate 1/second burst 3 packets } log prefix "outgoing_2 " level info flags skuid |
| 123 |
counter name "all_out" continue |
| 124 |
counter name "all_out_2" continue |
| 125 |
tcp sport 22 counter name "ssh_out" continue |
| 126 |
jump allow_icmp_4 |
| 127 |
ct state vmap { |
| 128 |
established : accept, |
| 129 |
related : accept, |
| 130 |
invalid : jump invalid_drop, |
| 131 |
new : jump smurfs_4, |
| 132 |
untracked : jump smurfs_4 |
| 133 |
} |
| 134 |
tcp dport 22 accept |
| 135 |
ip protocol igmp ip daddr 224.0.0.22 accept |
| 136 |
tcp dport 443 counter name "new_https" accept |
| 137 |
udp dport 443 counter name "new_https" accept |
| 138 |
update @_lograte_set_4 { ip saddr limit rate 1/second burst 3 packets } log prefix "post-ct,pre-reject " level info flags skuid |
| 139 |
reject with icmpx admin-prohibited |
| 140 |
} |
| 141 |
|
| 142 |
chain localhost-public_6 { |
| 143 |
update @_lograte_set_6 { ip6 saddr limit rate 1/second burst 3 packets } log prefix "outgoing " level info flags skuid |
| 144 |
update @_lograte_set_6 { ip6 saddr limit rate 1/second burst 3 packets } log prefix "outgoing_2 " level info flags skuid |
| 145 |
counter name "all_out" continue |
| 146 |
counter name "all_out_2" continue |
| 147 |
tcp sport 22 counter name "ssh_out" continue |
| 148 |
jump allow_icmp_6 |
| 149 |
ct state vmap { |
| 150 |
established : accept, |
| 151 |
related : accept, |
| 152 |
invalid : jump invalid_drop, |
| 153 |
new : jump smurfs_6, |
| 154 |
untracked : jump smurfs_6 |
| 155 |
} |
| 156 |
tcp dport 22 accept |
| 157 |
tcp dport 443 counter name "new_https" accept |
| 158 |
udp dport 443 counter name "new_https" accept |
| 159 |
update @_lograte_set_6 { ip6 saddr limit rate 1/second burst 3 packets } log prefix "post-ct,pre-reject " level info flags skuid |
| 160 |
reject with icmpx admin-prohibited |
| 161 |
} |
| 162 |
|
| 163 |
chain public-localhost { |
| 164 |
meta nfproto vmap { |
| 165 |
ipv4 : jump public-localhost_4, |
| 166 |
ipv6 : jump public-localhost_6 |
| 167 |
} |
| 168 |
} |
| 169 |
|
| 170 |
chain public-localhost_4 { |
| 171 |
update @_lograte_set_4 { ip saddr limit rate 1/second burst 3 packets } log prefix "incoming " level info flags skuid |
| 172 |
update @_lograte_set_4 { ip saddr limit rate 1/second burst 3 packets } log prefix "incoming_2 " level info flags skuid |
| 173 |
counter name "all_in" continue |
| 174 |
counter name "all_in_2" continue |
| 175 |
tcp dport 22 counter name "ssh_in" continue |
| 176 |
jump allow_icmp_4 |
| 177 |
ct state vmap { |
| 178 |
established : accept, |
| 179 |
related : accept, |
| 180 |
invalid : jump invalid_drop, |
| 181 |
new : jump smurfs_4, |
| 182 |
untracked : jump smurfs_4 |
| 183 |
} |
| 184 |
ip protocol igmp ip daddr 224.0.0.1 accept |
| 185 |
fib daddr type { broadcast, multicast } drop |
| 186 |
ct status dnat accept |
| 187 |
tcp dport 22 accept |
| 188 |
drop |
| 189 |
} |
| 190 |
|
| 191 |
chain public-localhost_6 { |
| 192 |
update @_lograte_set_6 { ip6 saddr limit rate 1/second burst 3 packets } log prefix "incoming " level info flags skuid |
| 193 |
update @_lograte_set_6 { ip6 saddr limit rate 1/second burst 3 packets } log prefix "incoming_2 " level info flags skuid |
| 194 |
counter name "all_in" continue |
| 195 |
counter name "all_in_2" continue |
| 196 |
tcp dport 22 counter name "ssh_in" continue |
| 197 |
jump allow_icmp_6 |
| 198 |
ct state vmap { |
| 199 |
established : accept, |
| 200 |
related : accept, |
| 201 |
invalid : jump invalid_drop, |
| 202 |
new : jump smurfs_6, |
| 203 |
untracked : jump smurfs_6 |
| 204 |
} |
| 205 |
fib daddr type multicast drop |
| 206 |
ct status dnat accept |
| 207 |
tcp dport 22 accept |
| 208 |
drop |
| 209 |
} |
| 210 |
|
| 211 |
chain localhost-localhost { |
| 212 |
meta nfproto vmap { |
| 213 |
ipv4 : jump localhost-localhost_4, |
| 214 |
ipv6 : jump localhost-localhost_6 |
| 215 |
} |
| 216 |
} |
| 217 |
|
| 218 |
chain localhost-localhost_4 { |
| 219 |
jump allow_icmp_4 |
| 220 |
ct state vmap { |
| 221 |
established : accept, |
| 222 |
related : accept, |
| 223 |
invalid : jump invalid_drop, |
| 224 |
new : jump smurfs_4, |
| 225 |
untracked : jump smurfs_4 |
| 226 |
} |
| 227 |
accept |
| 228 |
} |
| 229 |
|
| 230 |
chain localhost-localhost_6 { |
| 231 |
jump allow_icmp_6 |
| 232 |
ct state vmap { |
| 233 |
established : accept, |
| 234 |
related : accept, |
| 235 |
invalid : jump invalid_drop, |
| 236 |
new : jump smurfs_6, |
| 237 |
untracked : jump smurfs_6 |
| 238 |
} |
| 239 |
accept |
| 240 |
} |
| 241 |
|
| 242 |
chain public-public { |
| 243 |
meta nfproto vmap { |
| 244 |
ipv4 : jump public-public_4, |
| 245 |
ipv6 : jump public-public_6 |
| 246 |
} |
| 247 |
} |
| 248 |
|
| 249 |
chain public-public_4 { |
| 250 |
jump allow_icmp_4 |
| 251 |
ct state vmap { |
| 252 |
established : accept, |
| 253 |
related : accept, |
| 254 |
invalid : jump invalid_drop, |
| 255 |
new : jump smurfs_4, |
| 256 |
untracked : jump smurfs_4 |
| 257 |
} |
| 258 |
fib daddr type { broadcast, multicast } drop |
| 259 |
update @_lograte_set_4 { ip saddr limit rate 1/second burst 3 packets } log prefix "public-public DROP " level info flags skuid |
| 260 |
drop |
| 261 |
} |
| 262 |
|
| 263 |
chain public-public_6 { |
| 264 |
jump allow_icmp_6 |
| 265 |
ct state vmap { |
| 266 |
established : accept, |
| 267 |
related : accept, |
| 268 |
invalid : jump invalid_drop, |
| 269 |
new : jump smurfs_6, |
| 270 |
untracked : jump smurfs_6 |
| 271 |
} |
| 272 |
fib daddr type multicast drop |
| 273 |
update @_lograte_set_6 { ip6 saddr limit rate 1/second burst 3 packets } log prefix "public-public DROP " level info flags skuid |
| 274 |
drop |
| 275 |
} |
| 276 |
|
| 277 |
chain filter_prerouting_raw { |
| 278 |
type filter hook prerouting priority raw |
| 279 |
tcp dport 53 notrack |
| 280 |
udp dport 53 notrack |
| 281 |
tcp sport 53 notrack |
| 282 |
udp sport 53 notrack |
| 283 |
} |
| 284 |
|
| 285 |
chain filter_output_raw { |
| 286 |
type filter hook output priority raw |
| 287 |
tcp dport 53 notrack |
| 288 |
udp dport 53 notrack |
| 289 |
tcp sport 53 notrack |
| 290 |
udp sport 53 notrack |
| 291 |
} |
| 292 |
|
| 293 |
set _lograte_set_4 { |
| 294 |
type ipv4_addr |
| 295 |
size 65535 |
| 296 |
flags dynamic,timeout |
| 297 |
timeout 1m |
| 298 |
} |
| 299 |
|
| 300 |
set _lograte_set_6 { |
| 301 |
type ipv6_addr |
| 302 |
size 65535 |
| 303 |
flags dynamic,timeout |
| 304 |
timeout 1m |
| 305 |
} |
| 306 |
|
| 307 |
counter all_in { |
| 308 |
} |
| 309 |
|
| 310 |
counter all_in_2 { |
| 311 |
} |
| 312 |
|
| 313 |
counter all_out { |
| 314 |
} |
| 315 |
|
| 316 |
counter all_out_2 { |
| 317 |
} |
| 318 |
|
| 319 |
counter new_https { |
| 320 |
} |
| 321 |
|
| 322 |
counter ssh_in { |
| 323 |
} |
| 324 |
|
| 325 |
counter ssh_out { |
| 326 |
} |
| 327 |
|
| 328 |
chain rpfilter { |
| 329 |
type filter hook prerouting priority filter + 5 |
| 330 |
fib saddr . mark . iif oif 0 meta ipsec missing jump rpfilter_drop |
| 331 |
} |
| 332 |
|
| 333 |
} |