What's new

Custom firewall rules executed multiple times

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Hi Colin,

At reboot, your script works perfectly and applies the custom firewall rules at the top.
I have restarted the firewall manually and after that, the rules are applied on line 6, 7 and 8 (they are no longer at the top). This way the rules make no difference.

Do you know what is happening, please?

Thank you
 
Sure, please see below:

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 0 0 ACCEPT all -- ppp0 * 10.10.10.0/24 0.0.0.0/0
2 0 0 ACCEPT udp -- ppp0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:4500
3 2 118 ACCEPT udp -- ppp0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:500
4 0 0 ACCEPT ah -- ppp0 * 0.0.0.0/0 0.0.0.0/0
5 0 0 ACCEPT esp -- ppp0 * 0.0.0.0/0 0.0.0.0/0
6 0 0 ACCEPT tcp -- * * xxx.xxx.xxx.xxx 0.0.0.0/0 tcp dpt:xxx
7 0 0 ACCEPT tcp -- * * xxx.xxx.xxx.xxx 0.0.0.0/0 tcp dpt:xxx
8 9 368 DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:xxx
9 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:443
10 0 0 DROP udp -- br0 * 0.0.0.0/0 0.0.0.0/0 udp spt:500 dpt:500
11 0 0 DROP udp -- br0 * 0.0.0.0/0 0.0.0.0/0 udp spt:4500 dpt:4500
12 5 170 DROP icmp -- ppp0 * 0.0.0.0/0 0.0.0.0/0 icmptype 8
13 118K 23M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
14 2901 129K DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID
15 73291 14M PTCSRVWAN all -- !br0 * 0.0.0.0/0 0.0.0.0/0
16 31057 2083K PTCSRVLAN all -- br0 * 0.0.0.0/0 0.0.0.0/0
17 31057 2083K ACCEPT all -- br0 * 0.0.0.0/0 0.0.0.0/0 state NEW
18 68072 14M ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 state NEW
19 5219 331K OVPN all -- * * 0.0.0.0/0 0.0.0.0/0 state NEW
20 0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp spt:67 dpt:68
21 0 0 INPUT_ICMP icmp -- * * 0.0.0.0/0 0.0.0.0/0
22 5219 331K DROP all -- * * 0.0.0.0/0 0.0.0.0/0
 
I think that looks correct. You appear to have another VPN client server running. IPSec?
 
Last edited:
Yes, that's right, I have an IPSec server running alongside OpenVPN.
When I reboot the router, the OpenVPN rules are applied at the top, but when I restart the firewall they get demoted to line 6-8.
Is there a way to always keep them on 1-3?

Thank you.
 
FWIW, there are times when the firewall script is called multiple times and the previous firewall rules are NOT deleted. I've specifically seen this w/ tomato routers (of which Merlin is a variant), and seems to happen most often when using multiple bridges. It's as if each instance of a bridge results in a call to the firewall script. For this reason, I usually create my firewall script as follows:

Code:
ipt() {
    # precede insert/append w/ deletion to avoid dupes
    iptables ${@/-[IA]/-D} 2> /dev/null
    iptables $@
}

ipt -I INPUT -i br2 -j REJECT
ipt -I INPUT -i br2 -p tcp -j REJECT
...

IOW, every insertion is preceded w/ a deletion for the same rule just in case duplication takes place.
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top