nftables.conf 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # https://wiki.archlinux.org/index.php/Nftables#Usage
  2. # A simple and safe firewall
  3. flush ruleset
  4. table inet filter {
  5. chain input {
  6. type filter hook input priority 0; policy drop;
  7. iifname lo accept comment "Accept any localhost traffic"
  8. ct state invalid drop comment "drop invalid connections"
  9. ct state established,related accept comment "Accept traffic originated from us"
  10. # allow icmp, which is commonly used to see how long it takes packets to get somewhere
  11. # It helps people debug web applications
  12. ip protocol icmp icmp type { \
  13. destination-unreachable, router-solicitation, router-advertisement, time-exceeded, parameter-problem \
  14. } accept comment "Accept ICMP"
  15. ip6 nexthdr icmpv6 drop
  16. # IGMP is a protocol that help online gaming and video chat work better
  17. ip protocol igmp accept comment "Accept IGMP"
  18. udp dport mdns ip daddr 224.0.0.251 accept comment "Accept mDNS"
  19. udp sport 1900 udp dport >= 1024 ip saddr { \
  20. 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16 \
  21. } meta pkttype unicast limit rate 4/second burst 20 packets accept comment "Accept UPnP IGD port mapping reply"
  22. # No ping floods
  23. ip protocol icmp icmp type echo-request limit rate over 10/second burst 4 packets drop
  24. # allow ssh
  25. # can I disable this? I am not going to be ssh-ing into this laptop anytime soon.
  26. # tcp dport ssh accept
  27. # reject everything else
  28. reject with icmpx type port-unreachable
  29. }
  30. # this is a laptop. I do not forward stuff.
  31. chain forward {
  32. type filter hook forward priority 0; policy drop;
  33. }
  34. # I should probably work on this....I should only really enable certain outbound connections.
  35. chain output {
  36. type filter hook output priority 0; policy accept;
  37. }
  38. }