ferm.conf.j2 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. {% if ansible_prolog -%}
  2. {% from 'templates/ansible/prolog.j2' import prolog with context %}
  3. {{ prolog() }}
  4. {% endif -%}
  5. #
  6. # Configuration file for ferm(1).
  7. #
  8. @def $PORTS = (
  9. {%- if firewall_opened_ports -%}
  10. {% for port in firewall_opened_ports %}{{ port }} {% endfor %}
  11. {%- endif -%}
  12. {%- if ssh_port is defined -%}{{ ssh_port }} {%- endif -%}
  13. {%- if ssh_ports_extra is defined -%}
  14. {% for port in ssh_ports_extra %}{{ port }} {% endfor %}
  15. {%- endif -%}
  16. ); # Services running
  17. table filter {
  18. chain INPUT {
  19. policy DROP;
  20. # connection tracking
  21. mod state state INVALID DROP;
  22. mod state state (ESTABLISHED RELATED) ACCEPT;
  23. # allow local packages
  24. interface lo ACCEPT;
  25. # respond to ping
  26. proto icmp icmp-type echo-request ACCEPT;
  27. # standard ports we allow from the outside
  28. proto tcp dport $PORTS ACCEPT;
  29. }
  30. chain OUTPUT {
  31. policy ACCEPT;
  32. # connection tracking
  33. #mod state state INVALID DROP;
  34. mod state state (ESTABLISHED RELATED) ACCEPT;
  35. }
  36. chain FORWARD {
  37. policy DROP;
  38. # connection tracking
  39. mod state state INVALID DROP;
  40. mod state state (ESTABLISHED RELATED) ACCEPT;
  41. }
  42. }
  43. domain ip6 table filter {
  44. chain INPUT {
  45. policy DROP;
  46. # connection tracking
  47. mod state state INVALID DROP;
  48. mod state state (ESTABLISHED RELATED) ACCEPT;
  49. # allow ICMP (for neighbor solicitation, like ARP for IPv4)
  50. proto ipv6-icmp ACCEPT;
  51. # standard ports we allow from the outside
  52. proto tcp dport $PORTS ACCEPT;
  53. }
  54. chain OUTPUT {
  55. policy ACCEPT;
  56. # connection tracking
  57. #mod state state INVALID DROP;
  58. mod state state (ESTABLISHED RELATED) ACCEPT;
  59. }
  60. chain FORWARD {
  61. policy DROP;
  62. # connection tracking
  63. mod state state INVALID DROP;
  64. mod state state (ESTABLISHED RELATED) ACCEPT;
  65. }
  66. }