nftables.scm 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. (define-module (nftables)
  2. #:export (
  3. %gnucode-nftables-ruleset
  4. ))
  5. (define %gnucode-nftables-ruleset
  6. "
  7. flush ruleset
  8. table inet my_table {
  9. set LANv4 {
  10. type ipv4_addr
  11. flags interval
  12. elements = { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16 }
  13. }
  14. set LANv6 {
  15. type ipv6_addr
  16. flags interval
  17. elements = { fd00::/8, fe80::/10 }
  18. }
  19. chain my_input_lan {
  20. # accept Accept NFS
  21. # meta l4proto { tcp, udp } th dport 2049
  22. # accept PXE
  23. # udp sport { bootpc, 4011 } udp dport { bootps, 4011 } accept
  24. # accept tftp
  25. # udp dport tftp accept
  26. }
  27. chain my_input {
  28. type filter hook input priority filter; policy drop;
  29. # accept localhost traffic
  30. iif lo accept
  31. # drop invalid connections
  32. ct state invalid drop
  33. # accept traffic originated from us
  34. ct state established,related accept
  35. # accept ICMPv6
  36. meta l4proto ipv6-icmp accept
  37. # accept ICMP
  38. meta l4proto icmp accept
  39. # accept igmp
  40. ip protocol igmp accept
  41. # accept mdns
  42. udp dport mdns ip6 daddr ff02::fb accept
  43. # accept mdns
  44. udp dport mdns ip daddr 224.0.0.251 accept
  45. # accept private ip ranges
  46. ip6 saddr @LANv6 jump my_input_lan
  47. ip saddr @LANv4 jump my_input_lan
  48. # allow ssh access
  49. tcp dport ssh accept
  50. # allow IPP/IPPs whatever that is
  51. # tcp dport ipp accept
  52. # allow http and https
  53. tcp dport { http, https, 8008, 8080 } accept
  54. # Accept DHCPDISCOVER (for DHCP-Proxy)
  55. udp sport bootpc udp dport bootps ip saddr 0.0.0.0 ip daddr 255.255.255.255 accept
  56. }
  57. chain my_forward {
  58. type filter hook forward priority filter; policy drop;
  59. # Drop everything forwarded to us. We do not forward. That is routers job.
  60. }
  61. chain my_output {
  62. type filter hook output priority filter; policy accept;
  63. # Accept every outbound connection
  64. }
  65. }
  66. ")