[wellylug] Blocking bad IPs from server

John Durham johndurh at spunge.org
Fri Jan 26 11:30:10 NZDT 2007


andrej at paradise.net.nz wrote:
> Quoting John Durham <johndurh at spunge.org>:
>
>   
>>> But this is Linux, my friend. :)
>>>
>>> for i in `cat list-of-bad-ips`; do iptables -A INPUT -s $i -j DROP;
>>> done
>>>       
>> I gather there is some insight in that, but the syntax is unclear at 
>> best.
>>     
> It's very clear to me :)All we do is take a list of IPs stored in a
> file, create a loop that iterates over the list.  In the body of
> the loop the IPs get passed to iptables individually, and a rule
> to drop traffic from that IP is inserted.
> More beautified it will look like:
> for i in `cat list`;
>   do
>     iptables -A INPUT -s $i -j DROP;
>   done
> where $i is the variable from "for i in"
>
>
>   
>> Is it capable of handling a list contained in a text file?
>>     
> Yes.
>
>   
>> Can it distinguish between good or bad access attempts?
>>     
> No - hence the name of the list I was using.
>
>   
>> How effective is it please?
>>     
> It's as effective as denying ANY traffic from the originating IP.
>
>
> Cheers,
> Andrej
>
>
>   
That is much clearer, thanks. Just one last question. My file (list) is 
called "badips.txt" so how can this syntax be used to refer to it?

-- 
Regards, John Durham <http://modecideas.com/contact.html?sig>
Fax/Phone 64 4 5286786
Award winning web site at http://modecideas.com?sig
Server hosted on Ubuntu 4.10
PC-HELPERS list subscribe/unsub at http://modecideas.com/discuss.htm?sig
Good advice is like good paint- it only works if applied. 




More information about the wellylug mailing list