Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

iptables 'recent' stuff



dsr at tao.merseine.nu writes:

>> If I wanted to only log attemps that result in actual DROPs, how would
>> I implement that?
>
> iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW \
> -m recent --update --seconds 60 --hitcount 4 -j LOG --log-level \
> WARN --log-prefix SSH-TOO-FAST

So something like this in /etc/sysconfig/iptables would do what I
wanted?

-A INPUT -p tcp --dport 22 -m state --state NEW -m recent --name ssh --set
-A INPUT -p tcp --dport 22 -m state --state NEW -m recent --name ssh --update --seconds 60 --hitcount 4 -j LOG --log-level WARN --log-prefix SSH-TOO-FAST
-A INPUT -p tcp --dport 22 -m state --state NEW -m recent --name ssh --update --seconds 60 --hitcount 4 -j REJECT --reject-with icmp-host-prohibited

Wont this double-update the count, or even triple-update as 'set' will
update it as well?  Or will the --update only affect the hitcount once
per packet?  Should the log line be --rcheck instead of --update?  Or
should the REJECT line be --rcheck, on the assumption that the log
line updated the hitcount?  Or should both the log and reject lines
use --rcheck?

Question: is there some way to have a rule that if one 'recent'
check passed then I can set another one?  E.g., I'd like to be able
to do something like:

if packet matches XX, set badguy
if packet matches YY, set badguy if YY-hitcount >= 4
if packet matches ZZ, set badguy if ZZ-hitcount >= 6
if badguy, drop

I just don't know if you can have multiple "recent name" settings like
this?

-derek
-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org