ferm.conf.j2 2.0 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 = ({{ firewall_public | join(' ') }}); # Services running worldwide
  9. table filter {
  10. chain INPUT {
  11. policy DROP;
  12. # connection tracking
  13. mod state state INVALID DROP;
  14. mod state state (ESTABLISHED RELATED) ACCEPT;
  15. # allow local packet
  16. interface lo ACCEPT;
  17. # respond to ping
  18. proto icmp icmp-type echo-request ACCEPT;
  19. # standard ports we allow from the outside
  20. proto (udp tcp) dport $PORTS ACCEPT;
  21. {% if firewall_private is defined %}
  22. # Private networks configuration
  23. {% for fwconf in firewall_private %}
  24. interface {{ fwconf.interface }}{% if fwconf.network is defined %} saddr {{ fwconf.network }}{% endif %} {
  25. proto (udp tcp) dport ({{ fwconf.ports | join(' ') }}) ACCEPT;
  26. }
  27. {% endfor %}
  28. {% endif %}
  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. }