Like the OP, I'd prefer to use my own /etc/firewall.user.
'config include' does indeed pull in the firewall.user script, but I've found the custom chains (input_rule, output_rule, etc) are effectively ignored: the "zone" policy (ACCEPT/REJECT) gets enacted before the custom chains get called.
e.g. here's my config:
config defaults
option syn_flood 1
option input ACCEPT
option output ACCEPT
option forward REJECT
config zone
option name lan
option input ACCEPT
option output ACCEPT
option forward REJECT
config zone
option name wan
option input REJECT
option output ACCEPT
option forward REJECT
option masq 1
config include
option path /etc/firewall.user
here's an extract of the result, following the forward chain (observe that the custom chain, 'forwarding_rule', is after the zone 'forward'):
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 DROP all -- ...
3 188 TCPMSS tcp -- ...
91 33900 ACCEPT all -- ...
23 1232 forward all -- any any anywhere anywhere
0 0 forwarding_rule all -- any any anywhere anywhere
0 0 reject all -- any any anywhere anywhere
Chain forward (1 references)
pkts bytes target prot opt in out source destination
23 1232 zone_lan_forward all -- eth0.1 any anywhere anywhere
0 0 zone_wan_forward all -- ppp0 any anywhere anywhere
** And here's the problem:
Chain zone_lan_forward (1 references)
pkts bytes target prot opt in out source destination
23 1232 forwarding_lan all -- any any anywhere anywhere
0 0 zone_lan_REJECT all -- any any anywhere anywhere
So my custom chain will never get hit - zone_lan_REJECT terminates the chain. Of course, if I swap the zone policy from REJECT to PERMIT, it doesn't change anything - the chain still terminates. What I need is to be able to simply omit the desired chains altogether. I tried just leaving out the "options" I don't want (e.g. forward) but that raises errors in the firewall script.
I can't see an obvious way to do this, so I've simply patched uci_firewall.sh to include the custom chains before the zone ones:
--- /rom/lib/firewall/uci_firewall.sh Sun Oct 5 23:45:32 2008
+++ /lib/firewall/uci_firewall.sh Thu Oct 9 21:31:04 2008
@@ -162,6 +162,9 @@
$IPTABLES -N output
$IPTABLES -N forward
+ echo "Adding custom chains"
+ fw_custom_chains
+
$IPTABLES -A INPUT -j input
$IPTABLES -A OUTPUT -j output
$IPTABLES -A FORWARD -j forward
@@ -169,9 +172,6 @@
$IPTABLES -N reject
$IPTABLES -A reject -p tcp -j REJECT --reject-with tcp-reset
$IPTABLES -A reject -j REJECT --reject-with icmp-port-unreachable
-
- echo "Adding custom chains"
- fw_custom_chains
fw_set_chain_policy INPUT "$DEF_INPUT"
fw_set_chain_policy OUTPUT "$DEF_OUTPUT"
(Last edited by af3556 on 9 Oct 2008, 11:58)