2
0

02_enabled 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. Testing that not enabled rules are ignored.
  2. -- Testcase --
  3. {%
  4. include("./root/usr/share/firewall4/main.uc", {
  5. getenv: function(varname) {
  6. switch (varname) {
  7. case 'ACTION':
  8. return 'print';
  9. }
  10. }
  11. })
  12. %}
  13. -- End --
  14. -- File uci/helpers.json --
  15. {}
  16. -- End --
  17. -- File uci/firewall.json --
  18. {
  19. "rule": [
  20. {
  21. "proto": "any",
  22. "name": "Implicitly enabled"
  23. },
  24. {
  25. "proto": "any",
  26. "name": "Explicitly enabled",
  27. "enabled": "1"
  28. },
  29. {
  30. "proto": "any",
  31. "name": "Explicitly disabled",
  32. "enabled": "0"
  33. }
  34. ]
  35. }
  36. -- End --
  37. -- Expect stderr --
  38. [!] Section @rule[2] (Explicitly disabled) is disabled, ignoring section
  39. -- End --
  40. -- Expect stdout --
  41. table inet fw4
  42. flush table inet fw4
  43. table inet fw4 {
  44. #
  45. # Defines
  46. #
  47. #
  48. # User includes
  49. #
  50. include "/etc/nftables.d/*.nft"
  51. #
  52. # Filter rules
  53. #
  54. chain input {
  55. type filter hook input priority filter; policy drop;
  56. iif "lo" accept comment "!fw4: Accept traffic from loopback"
  57. ct state vmap { established : accept, related : accept } comment "!fw4: Handle inbound flows"
  58. }
  59. chain forward {
  60. type filter hook forward priority filter; policy drop;
  61. ct state vmap { established : accept, related : accept } comment "!fw4: Handle forwarded flows"
  62. }
  63. chain output {
  64. type filter hook output priority filter; policy drop;
  65. oif "lo" accept comment "!fw4: Accept traffic towards loopback"
  66. ct state vmap { established : accept, related : accept } comment "!fw4: Handle outbound flows"
  67. counter comment "!fw4: Implicitly enabled"
  68. counter comment "!fw4: Explicitly enabled"
  69. }
  70. chain prerouting {
  71. type filter hook prerouting priority filter; policy accept;
  72. }
  73. chain handle_reject {
  74. meta l4proto tcp reject with tcp reset comment "!fw4: Reject TCP traffic"
  75. reject with icmpx type port-unreachable comment "!fw4: Reject any other traffic"
  76. }
  77. #
  78. # NAT rules
  79. #
  80. chain dstnat {
  81. type nat hook prerouting priority dstnat; policy accept;
  82. }
  83. chain srcnat {
  84. type nat hook postrouting priority srcnat; policy accept;
  85. }
  86. #
  87. # Raw rules (notrack)
  88. #
  89. chain raw_prerouting {
  90. type filter hook prerouting priority raw; policy accept;
  91. }
  92. chain raw_output {
  93. type filter hook output priority raw; policy accept;
  94. }
  95. #
  96. # Mangle rules
  97. #
  98. chain mangle_prerouting {
  99. type filter hook prerouting priority mangle; policy accept;
  100. }
  101. chain mangle_postrouting {
  102. type filter hook postrouting priority mangle; policy accept;
  103. }
  104. chain mangle_input {
  105. type filter hook input priority mangle; policy accept;
  106. }
  107. chain mangle_output {
  108. type route hook output priority mangle; policy accept;
  109. }
  110. chain mangle_forward {
  111. type filter hook forward priority mangle; policy accept;
  112. }
  113. }
  114. -- End --