1 Testing the ruleset rendered from the default firewall configuration.
5 include("./root/usr/share/firewall4/main.uc", {
8 getenv: function(varname) {
28 hook ingress priority 0;
29 devices = { "br-lan", "wan" };
42 define lan_devices = { "br-lan" }
43 define lan_subnets = { 192.168.26.0/24, fd63:e2f:f706::/60 }
44 define wan_devices = { "wan" }
45 define wan_subnets = { 10.11.12.0/24 }
51 include "/etc/nftables.d/*.nft"
59 type filter hook input priority filter; policy accept;
61 iifname "lo" accept comment "!fw4: Accept traffic from loopback"
63 ct state established,related accept comment "!fw4: Allow inbound established and related flows"
64 tcp flags & (fin | syn | rst | ack) == syn jump syn_flood comment "!fw4: Rate limit TCP syn packets"
65 iifname "br-lan" jump input_lan comment "!fw4: Handle lan IPv4/IPv6 input traffic"
66 iifname "wan" jump input_wan comment "!fw4: Handle wan IPv4/IPv6 input traffic"
70 type filter hook forward priority filter; policy drop;
72 meta l4proto { tcp, udp } flow offload @ft;
73 ct state established,related accept comment "!fw4: Allow forwarded established and related flows"
74 iifname "br-lan" jump forward_lan comment "!fw4: Handle lan IPv4/IPv6 forward traffic"
75 iifname "wan" jump forward_wan comment "!fw4: Handle wan IPv4/IPv6 forward traffic"
80 type filter hook output priority filter; policy accept;
82 oifname "lo" accept comment "!fw4: Accept traffic towards loopback"
84 ct state established,related accept comment "!fw4: Allow outbound established and related flows"
85 oifname "br-lan" jump output_lan comment "!fw4: Handle lan IPv4/IPv6 output traffic"
86 oifname "wan" jump output_wan comment "!fw4: Handle wan IPv4/IPv6 output traffic"
90 meta l4proto tcp reject with tcp reset comment "!fw4: Reject TCP traffic"
91 reject with icmpx type port-unreachable comment "!fw4: Reject any other traffic"
95 tcp flags & (fin | syn | rst | ack) == syn limit rate 25/second burst 50 packets return comment "!fw4: Accept SYN packets below rate-limit"
96 drop comment "!fw4: Drop excess packets"
108 jump accept_to_wan comment "!fw4: Accept lan to wan forwarding"
112 chain accept_from_lan {
113 iifname "br-lan" counter accept comment "!fw4: accept lan IPv4/IPv6 traffic"
116 chain accept_to_lan {
117 oifname "br-lan" counter accept comment "!fw4: accept lan IPv4/IPv6 traffic"
121 meta nfproto ipv4 udp dport 68 counter accept comment "!fw4: Allow-DHCP-Renew"
122 meta nfproto ipv4 icmp type 8 counter accept comment "!fw4: Allow-Ping"
123 meta nfproto ipv4 meta l4proto igmp counter accept comment "!fw4: Allow-IGMP"
124 ip6 saddr fc00::/6 ip6 daddr fc00::/6 udp dport 546 counter accept comment "!fw4: Allow-DHCPv6"
125 ip6 saddr fe80::/10 icmpv6 type . icmpv6 code { 130 . 0, 131 . 0, 132 . 0, 143 . 0 } counter accept comment "!fw4: Allow-MLD"
126 meta nfproto ipv6 icmpv6 type { 128, 129, 1, 3, 133, 134 } limit rate 1000/second counter accept comment "!fw4: Allow-ICMPv6-Input"
127 meta nfproto ipv6 icmpv6 type . icmpv6 code { 2 . 0, 4 . 0, 4 . 1, 135 . 0, 136 . 0 } limit rate 1000/second counter accept comment "!fw4: Allow-ICMPv6-Input"
136 meta nfproto ipv6 icmpv6 type { 128, 129, 1, 3 } limit rate 1000/second counter accept comment "!fw4: Allow-ICMPv6-Forward"
137 meta nfproto ipv6 icmpv6 type . icmpv6 code { 2 . 0, 4 . 0, 4 . 1 } limit rate 1000/second counter accept comment "!fw4: Allow-ICMPv6-Forward"
138 meta l4proto esp counter jump accept_to_lan comment "!fw4: Allow-IPSec-ESP"
139 udp dport 500 counter jump accept_to_lan comment "!fw4: Allow-ISAKMP"
143 chain accept_to_wan {
144 oifname "wan" counter accept comment "!fw4: accept wan IPv4/IPv6 traffic"
147 chain reject_from_wan {
148 iifname "wan" counter jump handle_reject comment "!fw4: reject wan IPv4/IPv6 traffic"
151 chain reject_to_wan {
152 oifname "wan" counter jump handle_reject comment "!fw4: reject wan IPv4/IPv6 traffic"
161 type nat hook prerouting priority dstnat; policy accept;
165 type nat hook postrouting priority srcnat; policy accept;
166 oifname "wan" jump srcnat_wan comment "!fw4: Handle wan IPv4/IPv6 srcnat traffic"
170 meta nfproto ipv4 masquerade comment "!fw4: Masquerade IPv4 wan traffic"
175 # Raw rules (notrack & helper)
178 chain raw_prerouting {
179 type filter hook prerouting priority raw; policy accept;
180 iifname "br-lan" jump helper_lan comment "!fw4: lan IPv4/IPv6 CT helper assignment"
184 type filter hook output priority raw; policy accept;
188 type "amanda" protocol udp;
192 type "ftp" protocol tcp;
196 type "RAS" protocol udp;
200 type "Q.931" protocol tcp;
204 type "irc" protocol tcp;
207 ct helper netbios-ns {
208 type "netbios-ns" protocol udp;
212 type "pptp" protocol tcp;
216 type "sane" protocol tcp;
220 type "sip" protocol udp;
224 type "snmp" protocol udp;
228 type "tftp" protocol udp;
232 type "rtsp" protocol tcp;
236 meta l4proto udp udp dport 10080 ct helper set "amanda" comment "!fw4: Amanda backup and archiving proto"
237 meta l4proto tcp tcp dport 21 ct helper set "ftp" comment "!fw4: FTP passive connection tracking"
238 meta l4proto udp udp dport 1719 ct helper set "RAS" comment "!fw4: RAS proto tracking"
239 meta l4proto tcp tcp dport 1720 ct helper set "Q.931" comment "!fw4: Q.931 proto tracking"
240 meta nfproto ipv4 meta l4proto tcp tcp dport 6667 ct helper set "irc" comment "!fw4: IRC DCC connection tracking"
241 meta nfproto ipv4 meta l4proto udp udp dport 137 ct helper set "netbios-ns" comment "!fw4: NetBIOS name service broadcast tracking"
242 meta nfproto ipv4 meta l4proto tcp tcp dport 1723 ct helper set "pptp" comment "!fw4: PPTP VPN connection tracking"
243 meta l4proto tcp tcp dport 6566 ct helper set "sane" comment "!fw4: SANE scanner connection tracking"
244 meta l4proto udp udp dport 5060 ct helper set "sip" comment "!fw4: SIP VoIP connection tracking"
245 meta nfproto ipv4 meta l4proto udp udp dport 161 ct helper set "snmp" comment "!fw4: SNMP monitoring connection tracking"
246 meta l4proto udp udp dport 69 ct helper set "tftp" comment "!fw4: TFTP connection tracking"
247 meta nfproto ipv4 meta l4proto tcp tcp dport 554 ct helper set "rtsp" comment "!fw4: RTSP connection tracking"
255 chain mangle_prerouting {
256 type filter hook prerouting priority mangle; policy accept;
259 chain mangle_output {
260 type filter hook output priority mangle; policy accept;
263 chain mangle_forward {
264 type filter hook forward priority mangle; policy accept;
265 iifname "wan" tcp flags syn tcp option maxseg size set rt mtu comment "!fw4: Zone wan IPv4/IPv6 ingress MTU fixing"
266 oifname "wan" tcp flags syn tcp option maxseg size set rt mtu comment "!fw4: Zone wan IPv4/IPv6 egress MTU fixing"
272 [call] ctx.call object <network.interface> method <dump> args <null>
273 [call] ctx.call object <service> method <get_data> args <{ "type": "firewall" }>
274 [call] fs.open path </proc/version> mode <r>
275 [call] fs.stat path </sys/module/nf_conntrack_amanda>
276 [call] fs.stat path </sys/module/nf_conntrack_ftp>
277 [call] fs.stat path </sys/module/nf_conntrack_h323>
278 [call] fs.stat path </sys/module/nf_conntrack_h323>
279 [call] fs.stat path </sys/module/nf_conntrack_irc>
280 [call] fs.stat path </sys/module/nf_conntrack_netbios_ns>
281 [call] fs.stat path </sys/module/nf_conntrack_pptp>
282 [call] fs.stat path </sys/module/nf_conntrack_sane>
283 [call] fs.stat path </sys/module/nf_conntrack_sip>
284 [call] fs.stat path </sys/module/nf_conntrack_snmp>
285 [call] fs.stat path </sys/module/nf_conntrack_tftp>
286 [call] fs.stat path </sys/module/nf_conntrack_rtsp>
287 [call] fs.open path </sys/class/net/br-lan/flags> mode <r>
288 [call] fs.open path </sys/class/net/br-lan/flags> mode <r>