From: Mikhail <misha@mhsystems.com>
To: m@rtij.nl
Cc: netfilter@lists.netfilter.org
Subject: RE: Conntrack for related service
Date: Fri, 04 Aug 2006 23:53:48 -0400 [thread overview]
Message-ID: <000901c6b842$c19de2a0$4764a8c0@mhsystems.com> (raw)
In-Reply-To: <"52488.2001:888:19e1::53.1154621026.squirrel"@dexter>
-----Original Message-----
From: Martijn Lievaart [mailto:m@rtij.nl]
Sent: Thursday, August 03, 2006 12:04 PM
To: Mikhail
Cc: netfilter@lists.netfilter.org
Subject: Re: Conntrack for related service
Should be possible using reject. Something along these lines.
-A FORWARD -m state RELATED,ESTABLISHED -j ACCEPT
# Maybe you restrict this more, for now accept RMI from everywhere
-A FORWARD -p tcp -dport $rmiport -j RMI
-A FORWARD -p tcp -dport $mssql -j MSSQL
... other rules ...
-A RMI -p tcp --tcp-flags FIN FIN -j RMIFIN
-A RMI -m recent --name rmi --set
-A RMI -j ACCEPT
-A RMIFIN -m recent --name rmi --remove
-A RMIFIN -j ACCEPT
-A MSSQL -m recent --name rmi -rcheck -j ACCEPT
-A MSSQL -j LOG --prefix "mssql without rmi "
-A MSSQL -j DROP
HTH,
M4
Thanks' a lot for the script - it did the trick! Here is my updated version:
iptables -t mangle -N RMI
iptables -t mangle -N RMIFIN
iptables -t mangle -N MSSQL
iptables -t mangle -A PREROUTING -p tcp -d $external_ip --dport $rmi_port -j
RMI
iptables -t mangle -A PREROUTING -p tcp -d $external_ip --dport @mssql_port
-j MSSQL
iptables -t mangle -A RMI -p tcp --tcp-flags RST RST -j RMIFIN
iptables -t mangle -A RMI -p tcp --tcp-flags FIN FIN -j RMIFIN
iptables -t mangle -A RMI -m recent --name rmi --set
iptables -t mangle -A RMI -j ACCEPT
iptables -t mangle -A RMIFIN -m recent --name rmi --remove
#iptables -t mangle -A RMIFIN -j LOG --log-prefix "rmi fin "
iptables -t mangle -A RMIFIN -j ACCEPT
iptables -t mangle -A MSSQL -m recent --name rmi --rcheck -j ACCEPT
iptables -t mangle -A MSSQL -j LOG --log-prefix "mssql without rmi "
iptables -t mangle -A MSSQL -j DROP
I've placed this filter in mangle table before I do my DNAT. I've also added
the rule to clean up recent list in case of RST type of disconnect.
It seems to me though that script in this version has a flaw. Let's say
someone creates 2 instances of the same application with the same source
address and then closes one of them. I think this will effectively kill
MSSQL connection for the remaining instance. Is there any way to count RMI
connections originated from the same source IP and then start dropping MSSQL
requests only in case that count reaches 0?
Mikhail.
next parent reply other threads:[~2006-08-05 3:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <"52488.2001:888:19e1::53.1154621026.squirrel"@dexter>
2006-08-05 3:53 ` Mikhail [this message]
2006-08-05 9:32 ` Conntrack for related service Martijn Lievaart
2006-08-02 19:47 Mikhail
2006-08-03 11:13 ` Gáspár Lajos
2006-08-03 16:03 ` Martijn Lievaart
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='000901c6b842$c19de2a0$4764a8c0@mhsystems.com' \
--to=misha@mhsystems.com \
--cc=m@rtij.nl \
--cc=netfilter@lists.netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.