From: Mart Frauenlob <mart.frauenlob@chello.at>
Cc: Carsten Aulbert <carsten.aulbert@aei.mpg.de>, netfilter@vger.kernel.org
Subject: Re: SNAT and FIN/ACK packets after a long time
Date: Wed, 20 Jan 2010 16:23:53 +0100 [thread overview]
Message-ID: <4B572009.9020105@chello.at> (raw)
In-Reply-To: <201001201513.35390.carsten.aulbert@aei.mpg.de>
On 20.01.2010 15:13, Carsten Aulbert wrote:
> Hi all,
>
> we have a weird problem here, which we don't know if we understand it
> correctly:
>
> We have one "router" which uses netfilter/iptables to do SNAT and this works
> in principle. However, we have a program that seems to have a bug and leaves a
> connection open in CLOSE_WAIT state for (probably) a very long time (hours,
> days). Thus, the program probably receives a FIN but does not ACK that.
>
> Now, when we kill this program, it seems to realize it's error and sends the
> FIN/ACK packet out.
>
> Here we get a nice netfilter problem. It seems the packets arrive at the
> internal iface of the SNAT machine, go through the FORWARD chain, but then
> bypass the POSTROUTING chain, as we see the internally used 10.0.0.0/8
> addresses on the external iface going out into the world.
>
> Has anyone seen that?
>
> here's our SNAT from iptables-save:
>
> # Generated by iptables-save v1.4.2 on Wed Jan 20 15:12:02 2010
> *mangle
> :PREROUTING ACCEPT [33564248:152410100983]
> :INPUT ACCEPT [30142982:149275397517]
> :FORWARD ACCEPT [3415403:3134487334]
> :OUTPUT ACCEPT [22834014:4427390138]
> :POSTROUTING ACCEPT [26247062:7561729612]
> COMMIT
> # Completed on Wed Jan 20 15:12:02 2010
> # Generated by iptables-save v1.4.2 on Wed Jan 20 15:12:02 2010
> *nat
> :PREROUTING ACCEPT [426653254:210106871813]
> :POSTROUTING ACCEPT [86678890:27123554142]
> :OUTPUT ACCEPT [88632375:27265224806]
> -A POSTROUTING -o eth2 -j SNAT --to-source a.b.c.d
> -A POSTROUTING -s 10.0.0.0/8 -o eth2 -j LOG --log-prefix "BAD POSTROUTING: "
> COMMIT
> # Completed on Wed Jan 20 15:12:02 2010
> # Generated by iptables-save v1.4.2 on Wed Jan 20 15:12:02 2010
> *filter
> :INPUT DROP [682:213218]
> :FORWARD DROP [2918:175080]
> :OUTPUT ACCEPT [58195797:29502612523]
> :fail2ban-ssh - [0:0]
> -A INPUT -i eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT
> -A INPUT -i lo -j ACCEPT
> -A INPUT -i eth0 -j ACCEPT
> -A INPUT -i eth3 -j ACCEPT
> -A INPUT -p icmp -m icmp --icmp-type 8 -m state --state
> NEW,RELATED,ESTABLISHED -j ACCEPT
> -A INPUT -i eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT
> -A INPUT -i eth2 -p tcp -m tcp --dport 22 -j ACCEPT
> -A INPUT -i eth2 -p tcp -m tcp --dport 40000:45000 -j ACCEPT
> -A INPUT -i eth2 -p tcp -j REJECT --reject-with icmp-port-unreachable
> -A FORWARD -i eth0 -o eth2 -j ACCEPT
> -A FORWARD -i eth2 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
> -A OUTPUT -s 10.0.0.0/8 -o eth2 -j LOG --log-prefix "BAD OUTPUT: "
> -A OUTPUT -s 10.0.0.0/8 -o eth2 -j DROP
> COMMIT
> # Completed on Wed Jan 20 15:12:02 2010
>
> Is it possible that netfilter's connection tracker looses track of the old
> connections but does not drop this packet?
>
> Thanks for any hint
>
> Carsten
The connection tracking will most likely recognize those packet as in
'INVALID' state. You do not drop them (in FORWARD chain).
The nat table does not see packets in 'INVALID' state (needs
'normalized' connections).
-t filter ... -m state --state INVALID ... -j DROP
at a fitting place with additional matches at will.
best regards
Mart
next prev parent reply other threads:[~2010-01-20 15:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-20 14:13 SNAT and FIN/ACK packets after a long time Carsten Aulbert
2010-01-20 15:23 ` Mart Frauenlob [this message]
2010-01-20 15:39 ` Carsten Aulbert
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=4B572009.9020105@chello.at \
--to=mart.frauenlob@chello.at \
--cc=carsten.aulbert@aei.mpg.de \
--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