From: Alessandro Vesely <vesely@tana.it>
To: Mail List - Netfilter <netfilter@vger.kernel.org>
Subject: Re: Best way to kill a live TCP connection?
Date: Wed, 19 Jan 2011 14:32:51 +0100 [thread overview]
Message-ID: <4D36E803.4060703@tana.it> (raw)
In-Reply-To: <4D35DFC8.7000302@freemail.hu>
On 18/Jan/11 19:45, Gáspár Lajos wrote:
> Do you know the conntrack tool?
>
> conntrack -D...
Yes, I'm sorry I didn't leave more context in place. The thread was
about deleting connections as above and have iptables kill them as a
side effect.
>> I tried using connmark, as in
>>
>> iptables -A INPUT -m conntrack --ctstate NEW -p tcp ! --syn\
>> -j CONNMARK --or-mark 8
>> and
>> iptables -A OUTPUT -m connmark --mark 8/8 -p tcp ! --syn\
>> -j REJECT --reject-with tcp-reset
>>
>> However, the latter rule never matched. Is it the wrong table?
>
> Do you have more connmark rules? Maybe something interferencing whit
> these rules...
Not connmark --which I'm unfamiliar with-- but there was a sanity
check that I overlooked. Your question has put me on the right track.
Thanks!
Now, having fixed that, terminating connections this way apparently
works perfectly: issuing "conntrack -D -s x.x.x.x", the local end of
each connection to x.x.x.x is reset, thereby saving server's
resources, while malicious clients are left idling alone.
This seems about the best I can get. However, this method still has
two minor defects:
First, after I have determined that the client is malicious I have to
let in one more packet. This could be avoided using the
tcp-reset-destination iptables enhancement that I proposed.
Second, if such further packet never arrives, the server has to wait
until timeout. I think I'd need the seq/ack numbers of the last
packet in order to avoid this. They must be somewhere in the system,
don't they? (Or would it help to send spoofed packets to remote
clients at the time their maliciousess is determined, as other
methods* do?)
Further thoughts?
--
[*] see killcx or cutter, mentioned upthread.
next prev parent reply other threads:[~2011-01-19 13:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-11 12:35 Best way to kill a live TCP connection? Alessandro Vesely
2011-01-11 14:41 ` Jan Engelhardt
2011-01-11 16:21 ` Alessandro Vesely
2011-01-11 17:39 ` Pascal Hambourg
2011-01-11 21:10 ` Grant Taylor
2011-01-11 22:31 ` Jan Engelhardt
2011-01-12 8:52 ` Alessandro Vesely
2011-01-18 17:50 ` Alessandro Vesely
2011-01-18 18:45 ` Gáspár Lajos
2011-01-19 13:32 ` Alessandro Vesely [this message]
2011-01-12 0:20 ` Pablo Neira Ayuso
2011-01-12 0:20 ` Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D36E803.4060703@tana.it \
--to=vesely@tana.it \
--cc=netfilter@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox