ferm.conf.j2 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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.networks is defined %} saddr ({{ fwconf.networks | join(' ') }}){% 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 local packet
  50. interface lo ACCEPT;
  51. # allow ICMP (for neighbor solicitation, like ARP for IPv4)
  52. proto ipv6-icmp ACCEPT;
  53. # standard ports we allow from the outside
  54. proto tcp dport $PORTS ACCEPT;
  55. }
  56. chain OUTPUT {
  57. policy ACCEPT;
  58. # connection tracking
  59. #mod state state INVALID DROP;
  60. mod state state (ESTABLISHED RELATED) ACCEPT;
  61. }
  62. chain FORWARD {
  63. policy DROP;
  64. # connection tracking
  65. mod state state INVALID DROP;
  66. mod state state (ESTABLISHED RELATED) ACCEPT;
  67. }
  68. }