Jack Yaz
Part of the Furniture
I've noticed that when restarting VPN clients, there's often duplicate rules in the main table for iptables, e.g.
I've noticed that
isn't actually valid, there should be a space between account and --aaddr, so I'm not sure why iptables reports it this way. (bug?)
That aside, I've created a little script to run via cru that removes duplicates, and wanted to share for comments/suggestions for improvement!
Code:
-A iptfromlan -o eth0 -m account--aaddr 10.14.16.0/255.255.255.0 --aname lan -j RETURN
-A iptfromlan -o tun11 -m account--aaddr 10.14.16.0/255.255.255.0 --aname lan -j RETURN
-A iptfromlan -o tun12 -m account--aaddr 10.14.16.0/255.255.255.0 --aname lan -j RETURN
-A iptfromlan -o tun21 -m account--aaddr 10.14.16.0/255.255.255.0 --aname lan -j RETURN
-A iptfromlan -o tun11 -m account--aaddr 10.14.16.0/255.255.255.0 --aname lan -j RETURN
-A iptfromlan -o tun12 -m account--aaddr 10.14.16.0/255.255.255.0 --aname lan -j RETURN
-A iptfromlan -o tun11 -m account--aaddr 10.14.16.0/255.255.255.0 --aname lan -j RETURN
I've noticed that
Code:
-m account--aaddr
That aside, I've created a little script to run via cru that removes duplicates, and wanted to share for comments/suggestions for improvement!
Code:
#!/bin/sh
iptables-save | awk '/^COMMIT/ || !x[$0]++' > /tmp/iptables.bak
sed -i 's/account--aaddr/account --aaddr/g' /tmp/iptables.bak
iptables -F
iptables-restore < /tmp/iptables.bak
if [ -f /tmp/iptables.bak] ; then
rm -f /tmp/iptables.bak
fi