nftables.conf 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. flush ruleset
  2. table inet firewall {
  3. # allow all outbound traffic
  4. chain outbound {
  5. type filter hook output priority 0; policy accept;
  6. }
  7. # accept ip4 icmp with rate limit
  8. chain inbound_ipv4 {
  9. icmp type echo-request limit rate 5/second accept
  10. }
  11. # accept neighbor discovery and ip6 icmp with rate limit
  12. chain inbound_ipv6 {
  13. icmpv6 type { nd-neighbor-solicit, nd-router-advert, nd-neighbor-advert } accept
  14. icmpv6 type echo-request limit rate 5/second accept
  15. }
  16. # drop all inbound traffic that does not pass filters
  17. chain inbound {
  18. type filter hook input priority 0; policy drop;
  19. # Allow traffic from established and related packets, drop invalid
  20. ct state vmap { established: accept, related: accept, invalid: drop }
  21. # Allow loopback traffic
  22. iifname lo accept
  23. # Jump to chain according to layer 3 protocol using a verdict map
  24. meta protocol vmap { ip: jump inbound_ipv4, ip6: jump inbound_ipv6 }
  25. # allow http and https traffic
  26. tcp dport { 80, 443 } accept
  27. # rate limit new ssh connections
  28. tcp dport ssh ct state new limit rate 4/minute accept
  29. # log all denied traffic (including ssh)
  30. log prefix "[nftables] Inbound Denied: " counter drop
  31. }
  32. # do not act as a router; drop all forward requests
  33. chain forward {
  34. type filter hook forward priority 0; policy drop;
  35. }
  36. }