Linux Netfilter discussions
 help / color / mirror / Atom feed
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: Tue, 18 Jan 2011 18:50:10 +0100	[thread overview]
Message-ID: <4D35D2D2.3020201@tana.it> (raw)
In-Reply-To: <4D2CC740.9090007@riverviewtech.net>

Having tried it, it's rather tricky.  The behavior depends on when the
connection is deleted.  For example, with

   # input rule meant to drop incoming packets
   iptables -A INPUT -m conntrack --ctstate NEW -p tcp ! --syn\
      -j DROP
and
   # output rule to reset connections to the local server
   iptables -A OUTPUT -m conntrack --ctstate NEW -p tcp ! --syn\
      -j REJECT --reject-with tcp-reset

the connection is most likely deleted after the local server has sent
a reply but before the remote client sends a further commands.  In
this case the server will timeout waiting for those dropped input packets.

I tried removing that input rule.  That way the relevant packets are
accepted, but server's reply packets in the OUTPUT table are marked
ESTABLISHED again.

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?

-- 
BTW, I'v added a request for tcp-reset-both to the wish list
http://bugzilla.netfilter.org/show_bug.cgi?id=696 (I hope I'll still
be alive by the time it lands on debian ;-)  For debian users, lenny's
conntrack doesn't work, but v0.9.14 of squeeze does --see
http://marc.info/?l=netfilter&m=127653938407010&w=2 for pinning--
conntrack -D -s 1.2.3.4 works for me despite the bug in
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=496769 mentions 0.9.15.)

N.B. Despite announce of 15/09/10, I couldn't find conntrack 0.9.15 in
http://conntrack-tools.netfilter.org/downloads.html



  parent reply	other threads:[~2011-01-18 17:50 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 [this message]
2011-01-18 18:45           ` Gáspár Lajos
2011-01-19 13:32             ` Alessandro Vesely
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=4D35D2D2.3020201@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