Linux Netfilter discussions
 help / color / mirror / Atom feed
* Re: Re: need help in rate limiting tcp-syn !!
@ 2002-06-29 23:21 ganesh kumar godavari
  2002-06-30  5:35 ` George Georgalis
  0 siblings, 1 reply; 4+ messages in thread
From: ganesh kumar godavari @ 2002-06-29 23:21 UTC (permalink / raw)
  To: Antony Stone; +Cc: netfilter

hello anthony,
  can u please tell me how i can limit the # of packets from a  
tcp-syn flood and portscan from a particular ip(say a.b.c.d) from 
all kinds of attack if possible.


i badly need this i am currently performing some tests on DDOS and 
i need to figure this out. in a DDOS attack i want to limit the # 
of packets from a group of attack clients. i have to dynamically 
add the ip address and limit the # of packets from incomming 
attack clients.

can u please tell me how i can succefully protect my machine from 
a single attack client incase of 1) portscan and 2) tcp-syn 
flood.

Thanks for the help

---
ganesh






On Sun, 30 Jun 2002 Antony Stone wrote :
>On Saturday 29 June 2002 9:56 pm, ganesh kumar godavari wrote:
>
> >  hello group,
> >   i have attached my shell code to limit the  ping-icmp and
> > tcp-syn and tcp-portscan protection. i need some help in 
>this
> > matter.
> >
> > i am not able to limit the incoming tcp-syn packet and port 
>scan
> > packets done using nmap.
> >
> > i used nmap -sS -O -P0 -p1-15 <host name> for port scanning, 
>nmap
> > -sS -O -P0 <host name> for syn flooding.
>
> > $IPTABLES -N PORTSCANLIMIT
> > $IPTABLES -A PORTSCANLIMIT -p tcp --tcp-flags SYN,ACK,FIN,RST 
>RST
> > -m limit --limit $TCPSYNLIMIT --limit-burst $TCPSYNLIMITBURST 
>-j
> > ACCEPT
> > $IPTABLES -A PORTSCANLIMIT -p tcp --tcp-flags SYN,ACK,FIN,RST 
>RST
> > -j DROP
> > $IPTABLES -A PORTSCANLIMIT -j RETURN
>
>You're using -sS with nmap, which sends SYN packets, but your 
>portscanlimit
>rule is looking for packets with the RST flag set.
>
>The option "--tcp-flags SYN,ACK,FIN,RST RST" means "look at the 
>flags SYN,
>ACK, FIN and RST, and match if the RST flag (only) is set".
>
>If you want to match on only the SYN flag being set, then the 
>option should
>read "--tcp-flags SYN,ACK,FIN,RST SYN" (this will ignore the PSH 
>and URG
>flags).
>
>If you want to match on the SYN flag being set no matter what 
>other flags may
>be set as well, use "--tcp-flags SYN SYN".
>
>Remember that this is not the only way of doing a port scan with 
>nmap,
>however :-)
>
>
>
>Antony.
>

_________________________________________________________
There is always a better job for you at Monsterindia.com.
Go now http://monsterindia.com/rediffin/



^ permalink raw reply	[flat|nested] 4+ messages in thread
* need help in rate limiting tcp-syn !!
@ 2002-06-29 20:56 ganesh kumar godavari
  2002-06-29 22:48 ` Antony Stone
  0 siblings, 1 reply; 4+ messages in thread
From: ganesh kumar godavari @ 2002-06-29 20:56 UTC (permalink / raw)
  To: netfilter

[-- Attachment #1: Type: text/plain, Size: 2797 bytes --]


hello group,
  i have attached my shell code to limit the  ping-icmp and 
tcp-syn and tcp-portscan protection. i need some help in this 
matter.

i am not able to limit the incoming tcp-syn packet and port scan 
packets done using nmap.

i used nmap -sS -O -P0 -p1-15 <host name> for port scanning, nmap 
-sS -O -P0 <host name> for syn flooding.

can anyone tell me what is wrong!!. i am successfully able to 
limit the ping flood (ping -f <hostname>) from bib.cs.edu.

but when i repeat the experiment with tcp-syn flood and tcp port 
scan. i am not able to limit.

logically the rules look fine for me. but i am not able to do some 
rate limiting.

Thanks a mil

--
ganesh







#!/bin/sh

# This is the location of the iptables command
IPTABLES="/sbin/iptables"

EXTIF="eth0"
INTIF="eth1"

# Overall Limit for TCP-SYN-Flood detection
TCPSYNLIMIT="1/s"
# Burst Limit for TCP-SYN-Flood detection
TCPSYNLIMITBURST="5"
# Overall Limit for TCP-SYN-Flood detection
PINGLIMIT="1/s"
# Burst Limit for TCP-SYN-Flood detection
PINGLIMITBURST="5"


$IPTABLES -F
$IPTABLES -F -t mangle
$IPTABLES -F -t nat
$IPTABLES -X
$IPTABLES -X -t mangle
$IPTABLES -X -t nat

# Set up IP FORWARDing and Masquerading
$IPTABLES --table nat --append POSTROUTING --out-interface $EXTIF 
-j MASQUERADE
$IPTABLES --append FORWARD --in-interface $INTIF  -j ACCEPT

echo 1 > /proc/sys/net/ipv4/ip_forward             # Enables 
packet forwarding by kernel

$IPTABLES -P INPUT ACCEPT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT


$IPTABLES -N PORTSCANLIMIT
$IPTABLES -A PORTSCANLIMIT -p tcp --tcp-flags SYN,ACK,FIN,RST RST  
-m limit --limit $TCPSYNLIMIT --limit-burst $TCPSYNLIMITBURST -j 
ACCEPT
$IPTABLES -A PORTSCANLIMIT -p tcp --tcp-flags SYN,ACK,FIN,RST RST 
-j DROP
$IPTABLES -A PORTSCANLIMIT -j RETURN


$IPTABLES -N TCPACCEPT
$IPTABLES -A TCPACCEPT -p tcp --syn -m limit --limit $TCPSYNLIMIT 
--limit-burst $TCPSYNLIMITBURST -j ACCEPT
$IPTABLES -A TCPACCEPT -p tcp --syn -j DROP

$IPTABLES -A TCPACCEPT -p tcp -j PORTSCANLIMIT
$IPTABLES -A TCPACCEPT -j RETURN


$IPTABLES -N PINGACCEPT
$IPTABLES -A PINGACCEPT -p icmp --icmp-type echo-request -m limit 
--limit $PINGLIMIT --limit-burst $PINGLIMITBURST -j ACCEPT
$IPTABLES -A PINGACCEPT -p icmp --icmp-type echo-request -j DROP
$IPTABLES -A PINGACCEPT -p icmp -j RETURN


$IPTABLES -A INPUT -p tcp  -s bib.cs.edu -j TCPACCEPT
$IPTABLES -A INPUT -p icmp -s bib.cs.edu -j PINGACCEPT

#$IPTABLES -A TCPACCEPT -p tcp !--syn -j ACCEPT
#$IPTABLES -A INPUT -p tcp --syn  -j DROP

#IPTABLES -A INPUT -i $EXTIF  -j DROP
#$IPTABLES -A INPUT -i $EXTIF -p tcp  -j TCPACCEPT
#$IPTABLES -A INPUT -p tcp -j DROP



_________________________________________________________
There is always a better job for you at Monsterindia.com.
Go now http://monsterindia.com/rediffin/

[-- Attachment #2: Type: message/rfc822, Size: 4517 bytes --]

[-- Attachment #2.1.1: Notification --]
[-- Type: text/plain, Size: 429 bytes --]

This is the Postfix program at host lists.samba.org.

I'm sorry to have to inform you that the message returned
below could not be delivered to one or more destinations.

For further assistance, please contact <postmaster@samba.org>

If you do so, please include this problem report. You can
delete your own text from the message returned below.

			The Postfix program

<netfileter@lists.samba.org>: unknown user: "netfileter"


[-- Attachment #2.1.2: Undelivered Message --]
[-- Type: message/rfc822, Size: 3518 bytes --]

From: "ganesh kumar godavari" <gkgodava@rediffmail.com>
To: netfileter@lists.samba.org
Subject: help in rate limiting
Date: 29 Jun 2002 20:54:31 -0000
Message-ID: <20020629205431.20278.qmail@webmail6.rediffmail.com>

hello group,
  i have attached my shell code to limit the  ping-icmp and 
tcp-syn and tcp-portscan protection. i need some help in this 
matter.

i am not able to limit the incoming tcp-syn packet and port scan 
packets done using nmap.

i used nmap -sS -O -P0 -p1-15 <host name> for port scanning, nmap 
-sS -O -P0 <host name> for syn flooding.

can anyone tell me what is wrong!!. i am successfully able to 
limit the ping flood (ping -f <hostname>) from bib.cs.edu.

but when i repeat the experiment with tcp-syn flood and tcp port 
scan. i am not able to limit.

logically the rules look fine for me. but i am not able to do some 
rate limiting.

Thanks a mil

--
ganesh







#!/bin/sh

# This is the location of the iptables command
IPTABLES="/sbin/iptables"

EXTIF="eth0"
INTIF="eth1"

# Overall Limit for TCP-SYN-Flood detection
TCPSYNLIMIT="1/s"
# Burst Limit for TCP-SYN-Flood detection
TCPSYNLIMITBURST="5"
# Overall Limit for TCP-SYN-Flood detection
PINGLIMIT="1/s"
# Burst Limit for TCP-SYN-Flood detection
PINGLIMITBURST="5"


$IPTABLES -F
$IPTABLES -F -t mangle
$IPTABLES -F -t nat
$IPTABLES -X
$IPTABLES -X -t mangle
$IPTABLES -X -t nat

# Set up IP FORWARDing and Masquerading
$IPTABLES --table nat --append POSTROUTING --out-interface $EXTIF 
-j MASQUERADE
$IPTABLES --append FORWARD --in-interface $INTIF  -j ACCEPT

echo 1 > /proc/sys/net/ipv4/ip_forward             # Enables 
packet forwarding by kernel

$IPTABLES -P INPUT ACCEPT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT


$IPTABLES -N PORTSCANLIMIT
$IPTABLES -A PORTSCANLIMIT -p tcp --tcp-flags SYN,ACK,FIN,RST RST  
-m limit --limit $TCPSYNLIMIT --limit-burst $TCPSYNLIMITBURST -j 
ACCEPT
$IPTABLES -A PORTSCANLIMIT -p tcp --tcp-flags SYN,ACK,FIN,RST RST 
-j DROP
$IPTABLES -A PORTSCANLIMIT -j RETURN


$IPTABLES -N TCPACCEPT
$IPTABLES -A TCPACCEPT -p tcp --syn -m limit --limit $TCPSYNLIMIT 
--limit-burst $TCPSYNLIMITBURST -j ACCEPT
$IPTABLES -A TCPACCEPT -p tcp --syn -j DROP

$IPTABLES -A TCPACCEPT -p tcp -j PORTSCANLIMIT
$IPTABLES -A TCPACCEPT -j RETURN


$IPTABLES -N PINGACCEPT
$IPTABLES -A PINGACCEPT -p icmp --icmp-type echo-request -m limit 
--limit $PINGLIMIT --limit-burst $PINGLIMITBURST -j ACCEPT
$IPTABLES -A PINGACCEPT -p icmp --icmp-type echo-request -j DROP
$IPTABLES -A PINGACCEPT -p icmp -j RETURN


$IPTABLES -A INPUT -p tcp  -s bib.cs.edu -j TCPACCEPT
$IPTABLES -A INPUT -p icmp -s bib.cs.edu -j PINGACCEPT

#$IPTABLES -A TCPACCEPT -p tcp !--syn -j ACCEPT
#$IPTABLES -A INPUT -p tcp --syn  -j DROP

#IPTABLES -A INPUT -i $EXTIF  -j DROP
#$IPTABLES -A INPUT -i $EXTIF -p tcp  -j TCPACCEPT
#$IPTABLES -A INPUT -p tcp -j DROP


_________________________________________________________
There is always a better job for you at Monsterindia.com.
Go now http://monsterindia.com/rediffin/


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-06-30  5:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-29 23:21 Re: need help in rate limiting tcp-syn !! ganesh kumar godavari
2002-06-30  5:35 ` George Georgalis
  -- strict thread matches above, loose matches on Subject: below --
2002-06-29 20:56 ganesh kumar godavari
2002-06-29 22:48 ` Antony Stone

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox