loading huge number of rules in iptables (blocklist)




Hello,

I am playing round with the blocklist file obtained from peerguardian (level1.gz). I have written a bash function which I call in my iptables script to load these rules.

The following function actually loads the rules from a gzipped file (e.g. /etc/firewall/level1.gz, defined by the P2PBLOCKLISTFILE variable)

#function that creats the rules to block the traffic from blocked list
function FuncBlockedIPsRules {
echo "Making rules for Blocked IPs traffic";
while read Line; do
#get the ip address range from the file
IpRange=`echo -n $Line | sed -e 's/.*:\(.*\)-\(.*\)/\1-\2/'`;
#drop the traffic from this port range
$IPTABLES -A ${CHN_BTBLOCKEDIPS} \
-m iprange --src-range $IpRange -j DROP
done < <(zcat ${P2PBLOCKLISTFILE} | iconv -f latin1 -t utf-8 - | dos2unix)
}


Now, currently, there are around 151,000 ipranges listed in level1.gz to block. So the above function's loop goes over these many times inserting the rules for each range. And this is taking huge amount of time: in over 50 minutes, only around 12% rules have been loaded on my router running Etch (Pentium III, 449MHz, 380 MB RAM).

How can I speed this up? Advice?

thanks,
->HS


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx



Relevant Pages

  • RE: How do I make my NIC pick the same ETH port every time?
    ... Technical Manager, Uptime Technical Solutions LLC. ... It is conflicting with a firewire controller... ... load as modules then i can put a wait between them, ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: How do I make my NIC pick the same ETH port every time?
    ... It is conflicting with a firewire controller... ... load as modules then i can put a wait between them, ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ... Trouble? ...
    (Debian-User)
  • Re: x window / starting the desktop
    ... it will do all this and give you separate login windows on each ... I've been forced to because KDM has stopped working. ... me I cannot get it to load. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: No-Script, was: Re: [OT] google earth 5.0
    ... In terms of speed - with No-script disabled, the javascript on many ... that the web page has a script running that is taking a bit too long. ... load this web page. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • RE: no support!
    ... >>would not rally set CD to be the first device to load from. ... Kind regards, ... To unsubscribe, ...
    (freebsd-questions)