1 Testing an ipset declaration. 2 3 -- Testcase -- 4 {% 5 include("./root/usr/share/firewall4/main.uc", { 6 getenv: function(varname) { 7 switch (varname) { 8 case 'ACTION': 9 return 'print'; 10 } 11 } 12 }) 13 %} 14 -- End -- 15 16 -- File uci/helpers.json -- 17 {} 18 -- End -- 19 20 -- File fs/open~set-entries_txt.txt -- 21 10.11.12.13 53 22 172.16.27.1 443 23 -- End -- 24 25 -- File uci/firewall.json -- 26 { 27 "ipset": [ 28 { 29 "name": "test-set", 30 "comment": "A simple set", 31 "counters": "1", 32 "family": "IPv4", 33 "match": [ "src_ip", "dest_port" ], 34 "timeout": "600", 35 "maxelem": "1000", 36 "entry": [ 37 "1.2.3.4 80", 38 "5.6.7.8 22" 39 ], 40 "loadfile": "set-entries.txt" 41 } 42 ] 43 } 44 -- End -- 45 46 -- Expect stdout -- 47 table inet fw4 48 flush table inet fw4 49 50 table inet fw4 { 51 # 52 # Set definitions 53 # 54 55 set test-set { 56 comment "A simple set" 57 type ipv4_addr . inet_service 58 size 1000 59 timeout 600s 60 counter 61 flags timeout 62 elements = { 63 1.2.3.4 . 80, 64 5.6.7.8 . 22, 65 10.11.12.13 . 53, 66 172.16.27.1 . 443, 67 } 68 } 69 70 71 # 72 # Defines 73 # 74 75 76 # 77 # User includes 78 # 79 80 include "/etc/nftables.d/*.nft" 81 82 83 # 84 # Filter rules 85 # 86 87 chain input { 88 type filter hook input priority filter; policy drop; 89 90 iif "lo" accept comment "!fw4: Accept traffic from loopback" 91 92 ct state vmap { established : accept, related : accept } comment "!fw4: Handle inbound flows" 93 } 94 95 chain forward { 96 type filter hook forward priority filter; policy drop; 97 98 ct state vmap { established : accept, related : accept } comment "!fw4: Handle forwarded flows" 99 } 100 101 chain output { 102 type filter hook output priority filter; policy drop; 103 104 oif "lo" accept comment "!fw4: Accept traffic towards loopback" 105 106 ct state vmap { established : accept, related : accept } comment "!fw4: Handle outbound flows" 107 } 108 109 chain prerouting { 110 type filter hook prerouting priority filter; policy accept; 111 } 112 113 chain handle_reject { 114 meta l4proto tcp reject with tcp reset comment "!fw4: Reject TCP traffic" 115 reject with icmpx type port-unreachable comment "!fw4: Reject any other traffic" 116 } 117 118 119 # 120 # NAT rules 121 # 122 123 chain dstnat { 124 type nat hook prerouting priority dstnat; policy accept; 125 } 126 127 chain srcnat { 128 type nat hook postrouting priority srcnat; policy accept; 129 } 130 131 132 # 133 # Raw rules (notrack) 134 # 135 136 chain raw_prerouting { 137 type filter hook prerouting priority raw; policy accept; 138 } 139 140 chain raw_output { 141 type filter hook output priority raw; policy accept; 142 } 143 144 145 # 146 # Mangle rules 147 # 148 149 chain mangle_prerouting { 150 type filter hook prerouting priority mangle; policy accept; 151 } 152 153 chain mangle_postrouting { 154 type filter hook postrouting priority mangle; policy accept; 155 } 156 157 chain mangle_input { 158 type filter hook input priority mangle; policy accept; 159 } 160 161 chain mangle_output { 162 type route hook output priority mangle; policy accept; 163 } 164 165 chain mangle_forward { 166 type filter hook forward priority mangle; policy accept; 167 } 168 } 169 -- End --
This page was automatically generated by LXR 0.3.1. • OpenWrt