Networking Forums

Networking Forums > Computer Networking > Linux Networking > Blocking long list of IPs in iptables?

Reply
Thread Tools Display Modes

Blocking long list of IPs in iptables?

 
 
Jem Berkes
Guest
Posts: n/a

 
      09-25-2003, 01:57 AM
I have a list of 11000 IPs (from a wormtrap) that have attempted to send me
worms in the past couple days. Only 2000 of these IPs are unique; I
therefore think it might be worth blocking those IP addresses until this
flood ends.

By the way I'd be happy to share this list if anybody wants it. WARNING:
some major ISPs' mail relays are likely listed.

I know with iptables I can do:
iptables -A INPUT -p tcp -s 123.123.123.123 --dport smtp -j DROP

for each IP address, but before I went ahead and did this for each of those
2000 IPs I wanted to check to see if there was a 'better way' to do this?

--
Jem Berkes
http://www.sysdesign.ca/
 
Reply With Quote
 
 
 
 
Paul Lutus
Guest
Posts: n/a

 
      09-25-2003, 03:01 AM
Jem Berkes wrote:

> I have a list of 11000 IPs (from a wormtrap) that have attempted to send
> me worms in the past couple days. Only 2000 of these IPs are unique; I
> therefore think it might be worth blocking those IP addresses until this
> flood ends.


This is silly. Most of these worms are emanating from individual machines
with temporary IPs. In five minutes, the user logs off and the IP is
reassigned to someone who might have a legitimate reason to contact you.

The alternative is to block the entire domain, but that's worse in terms of
throwing out the baby with the bathwater.

--
Paul Lutus
http://www.arachnoid.com

 
Reply With Quote
 
Jem Berkes
Guest
Posts: n/a

 
      09-25-2003, 03:25 AM
>> I have a list of 11000 IPs (from a wormtrap) that have attempted to
>> send me worms in the past couple days. Only 2000 of these IPs are
>> unique; I therefore think it might be worth blocking those IP
>> addresses until this flood ends.

>
> This is silly. Most of these worms are emanating from individual
> machines with temporary IPs. In five minutes, the user logs off and
> the IP is reassigned to someone who might have a legitimate reason to
> contact you.


What I meant to say was there were 11000 connections specifically intended
to send the worm (none of these were legitimate mail). But among all those
connections, only 2000 were from unique IP addresses. This means that 9000
connections (or 82%) were repeats, new worms from the same IP address.

If the user logged off within a few minutes I would not be getting such a
high percentage of repeats. The scenario I'm imagining is an infected
machine sitting there for days on end, repeatedly sending me worms. For
instance: get worm form 209.225.8.xx at 10:00... then get worms again from
same IP half an hour later, two hours later, 3 hours later, 5 hours, 8,
hours, etc. on for days.

I think that type of situation is accounting for the 82% repeats.

 
Reply With Quote
 
Adam Dyga
Guest
Posts: n/a

 
      09-25-2003, 09:26 PM
Jem Berkes wrote:

> I have a list of 11000 IPs (from a wormtrap) that have attempted to send
> me worms in the past couple days. Only 2000 of these IPs are unique; I
> therefore think it might be worth blocking those IP addresses until this
> flood ends.
>
> By the way I'd be happy to share this list if anybody wants it. WARNING:
> some major ISPs' mail relays are likely listed.
>
> I know with iptables I can do:
> iptables -A INPUT -p tcp -s 123.123.123.123 --dport smtp -j DROP
>
> for each IP address, but before I went ahead and did this for each of
> those 2000 IPs I wanted to check to see if there was a 'better way' to do
> this?


use 'while' loop in bash, for example:

while read $ip
do
iptable_rule $ip
done < ips_file


--
Greets
adeon
 
Reply With Quote
 
Leon The Peon
Guest
Posts: n/a

 
      09-29-2003, 05:30 AM

"Jem Berkes" <(E-Mail Removed)_org> wrote in message
news:Xns9400D53AED07Bjbuserspc9org@130.179.16.24.. .
> I have a list of 11000 IPs (from a wormtrap) that have attempted to send

me
> worms in the past couple days. Only 2000 of these IPs are unique; I
> therefore think it might be worth blocking those IP addresses until this
> flood ends.
>
> By the way I'd be happy to share this list if anybody wants it. WARNING:
> some major ISPs' mail relays are likely listed.
>
> I know with iptables I can do:
> iptables -A INPUT -p tcp -s 123.123.123.123 --dport smtp -j DROP
>
> for each IP address, but before I went ahead and did this for each of

those
> 2000 IPs I wanted to check to see if there was a 'better way' to do this?


Maybe the better way is to get your mail server to recognise and drop such
worm mail.







---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 23/09/2003


 
Reply With Quote
 
Jem Berkes
Guest
Posts: n/a

 
      09-29-2003, 06:40 AM
> Maybe the better way is to get your mail server to recognise and drop
> such worm mail.


That's ok to do now, but I'm working on a contingency plan for the next
time my site gets totally swamped with traffic and I have to stop the SMTP
connections from even happening.

Here's what I've come up with:

1) grep out the IPs that are causing trouble
2) sort iplist | uniq > banlist
3) xargs -rl iptables -A INPUT -p tcp --dport smtp -j DROP -s < banlist

--
Jem Berkes
http://www.sysdesign.ca/
 
Reply With Quote
 
Kenneth Porter
Guest
Posts: n/a

 
      09-29-2003, 11:42 PM
Jem Berkes <(E-Mail Removed)9__org> wrote in
news:Xns9405111737791jbuserspc9org@130.179.16.24:

> 3) xargs -rl iptables -A INPUT -p tcp --dport smtp -j DROP -s < banlist


I'd suggest using a sub-table so you can enable/disable the banlist with
one iptables command:

iptables -A INPUT -p tcp --dport smtp -j smtpbanlist

--
Kenneth Porter
http://www.sewingwitch.com/ken/
 
Reply With Quote
 
Jem Berkes
Guest
Posts: n/a

 
      09-30-2003, 12:19 AM
>> 3) xargs -rl iptables -A INPUT -p tcp --dport smtp -j DROP -s < banlist
>
> I'd suggest using a sub-table so you can enable/disable the banlist with
> one iptables command:
>
> iptables -A INPUT -p tcp --dport smtp -j smtpbanlist


That's a nice idea. I never really learned iptables properly though so I'll
have to look into how this works.

--
Jem Berkes
http://www.sysdesign.ca/
 
Reply With Quote
 
Kenneth Porter
Guest
Posts: n/a

 
      09-30-2003, 04:30 PM
Jem Berkes <(E-Mail Removed)9__org> wrote in
news:Xns9405C495B5196jbuserspc9org@130.179.16.24:

> That's a nice idea. I never really learned iptables properly though so
> I'll have to look into how this works.


If you're a programmer, think subroutines, and think of "-j" to a subtable
as a conditional "call" statement.

--
Kenneth Porter
http://www.sewingwitch.com/ken/
 
Reply With Quote
 
psychopenguin
Guest
Posts: n/a

 
      10-10-2003, 05:30 PM
Jem Berkes wrote:
> I have a list of 11000 IPs (from a wormtrap) that have attempted to send me
> worms in the past couple days. Only 2000 of these IPs are unique; I
> therefore think it might be worth blocking those IP addresses until this
> flood ends.
>
> By the way I'd be happy to share this list if anybody wants it. WARNING:
> some major ISPs' mail relays are likely listed.
>
> I know with iptables I can do:
> iptables -A INPUT -p tcp -s 123.123.123.123 --dport smtp -j DROP
>
> for each IP address, but before I went ahead and did this for each of those
> 2000 IPs I wanted to check to see if there was a 'better way' to do this?
>

Why don't you just use an access list for Sendmail?

123.123.123.123 REJECT
123.xxx.xxx.xxx REJECT
etc....

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is difference of SYNC, ASYNC, BLOCKING, NON-BLOCKING sockets? kevin Linux Networking 0 11-21-2005 09:56 AM
IPTABLES: list all chain names Thomas Scheffler Linux Networking 0 11-12-2004 08:50 AM
Blocking netbios to the internet with iptables john Linux Networking 0 01-03-2004 08:00 PM
iptables: how to list tables? timeOday Linux Networking 5 10-03-2003 10:15 AM



1 2 3 4 5 6 7 8 9 10 11