This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new!

Improved grep/script

Posted by: Anonymous [ip:] on November 19, 2007 05:50 PM
I think you could change your grep/sed pipe to a single grep command (which I imagine would be slightly more efficient):

grep '^[^#]' /your/path/ip_msn

This should output any lines that start with something other than #, which also skips blank lines (because they start with nothing). I also think your loop could be rewritten like this to avoid the temporary file:

for IP in $(grep '^[^#]' /your/path/ip_msn) ; do
/sbin/iptables -t mangle -A PREROUTING -s $IP -p tcp --dport 1863 -j REJECT




Return to Blocking specific network applications with iptables