nat table remenbering nat's
Dear All
Why NAT rules stays valid even if I flush nat anf table chains??
I have:
iptables -P FORWARD DROP
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A FORWARD -s SOME_IP -d SOME_BCP_5_IP --dport 1234 -j ACCEPT
iptables -i nat -A PREROUTING -s SOME_IP -d MY_INTERNET_IP \\
--dport 1234 -j DNAT --to-destination SOME_BCP_5_IPThe conection is established and the data is flowing normaly. Suddenly I decide to not authorize this data flow anymore. So I
iptables -t nat -F PREROUTING
iptables -F FORWARD
For my surprise the data flow (observed with tcpdump) is still there! It is like the state machine does not let go this data flow.
What to do to block this data flow??
Is there any way to flush the conntrack database?
Regards
Signature · 8 lines
Ethy H. Brito /"\ InterNexo Ltda. \ / CAMPANHA DA FITA ASCII - CONTRA MAIL HTML +55 (12) 3941-6860 X ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL S.J.Campos - Brasil / \ _______________________________________________ LARTC mailing list [email protected] http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
Doesn't the policy change to ACCEPT after you flush the rules? Try an iptables -L -v -n after doing iptables -F and see what the default policy says.
- Greg Scott
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ethy H. Brito
Sent: Thursday, January 26, 2006 8:09 AM
To: [email protected]
Subject: [LARTC] nat table remenbering nat's
Dear All
Why NAT rules stays valid even if I flush nat anf table chains??
I have:
iptables -P FORWARD DROP
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A FORWARD -s SOME_IP -d SOME_BCP_5_IP --dport 1234 -j ACCEPT
iptables -i nat -A PREROUTING -s SOME_IP -d MY_INTERNET_IP \\
--dport 1234 -j DNAT --to-destination SOME_BCP_5_IPThe conection is established and the data is flowing normaly. Suddenly I decide to not authorize this data flow anymore. So I
iptables -t nat -F PREROUTING
iptables -F FORWARD
For my surprise the data flow (observed with tcpdump) is still there! It is like the state machine does not let go this data flow.
What to do to block this data flow??
Is there any way to flush the conntrack database?
Regards
Signature · 12 lines
Ethy H. Brito /"\ InterNexo Ltda. \ / CAMPANHA DA FITA ASCII - CONTRA MAIL HTML +55 (12) 3941-6860 X ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL S.J.Campos - Brasil / \ _______________________________________________ LARTC mailing list [email protected] http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc _______________________________________________ LARTC mailing list [email protected] http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
Quoted 3 lines · On Thu, 26 Jan 2006 08:22:51 -0600 "Greg Scott"…
Doesn't the policy change to ACCEPT after you flush the rules? Try an iptables -L -v -n after doing iptables -F and see what the default policy says.
Yes it does. It changes to ACCEPT in all chains.
So you are saying that I cannot stop the pre-established data flow because it will keep flowing because the default policy changed to ACCEPT updating the timout timer? But I flushed nat table. This should kill all conntrack entries related to the rules on this table.
Ethy
Quoted 48 lines
- Greg Scott
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ethy H. Brito
Sent: Thursday, January 26, 2006 8:09 AM
To: [email protected]
Subject: [LARTC] nat table remenbering nat'sDear All
Why NAT rules stays valid even if I flush nat anf table chains??
I have:
iptables -P FORWARD DROP
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A FORWARD -sSOME_IP-dSOME_BCP_5_IP--dport 1234 -j ACCEPTiptables -i nat -A PREROUTING -s SOME_IP -d MY_INTERNET_IP \\ --dport 1234 -j DNAT --to-destination SOME_BCP_5_IPThe conection is established and the data is flowing normaly. Suddenly I decide to not authorize this data flow anymore. So I
iptables -t nat -F PREROUTING
iptables -F FORWARDFor my surprise the data flow (observed with tcpdump) is still there! It is like the state machine does not let go this data flow.
What to do to block this data flow??
Is there any way to flush the conntrack database?Regards
Signature · 8 lines
Ethy H. Brito /"\ InterNexo Ltda. \ / CAMPANHA DA FITA ASCII - CONTRA MAIL HTML +55 (12) 3941-6860 X ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL S.J.Campos - Brasil / \ _______________________________________________ LARTC mailing list [email protected] http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
Signature · 8 lines
Ethy H. Brito /"\ InterNexo Ltda. \ / CAMPANHA DA FITA ASCII - CONTRA MAIL HTML +55 (12) 3941-6860 X ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL S.J.Campos - Brasil / \ _______________________________________________ LARTC mailing list [email protected] http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
No, it just flushes the rules and changes the policy to ACCEPT. The connections are still connected. I do this all the time with firewalls up and running. If flushing the rules killed all the active connections, it would be super disruptive.
I suppose if you want to stop connections, flush the rules and then set the policy to DROP - do 2 commands instead of just flushing.
Take what I say for what it's worth. I am not a netfilter developer, just a long-time user.
- Greg
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ethy H. Brito
Sent: Thursday, January 26, 2006 8:51 AM
Cc: [email protected]
Subject: Re: [LARTC] nat table remenbering nat's
Quoted 4 lines · On Thu, 26 Jan 2006 08:22:51 -0600 "Greg Scott"…
Doesn't the policy change to ACCEPT after you flush the rules? Try an
iptables -L -v -n after doing iptables -F and see what the default policy says.
Yes it does. It changes to ACCEPT in all chains.
So you are saying that I cannot stop the pre-established data flow because it will keep flowing because the default policy changed to ACCEPT updating the timout timer? But I flushed nat table. This should kill all conntrack entries related to the rules on this table.
Ethy
Quoted 49 lines
- Greg Scott
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ethy H. Brito
Sent: Thursday, January 26, 2006 8:09 AM
To: [email protected]
Subject: [LARTC] nat table remenbering nat'sDear All
Why NAT rules stays valid even if I flush nat anf table chains??
I have:
iptables -P FORWARD DROP
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A FORWARD -sSOME_IP-dSOME_BCP_5_IP--dport 1234 -j ACCEPTiptables -i nat -A PREROUTING -s SOME_IP -d MY_INTERNET_IP \\ --dport 1234 -j DNAT --to-destination SOME_BCP_5_IPThe conection is established and the data is flowing normaly. Suddenly I decide to not authorize this data flow anymore. So I
iptables -t nat -F PREROUTING
iptables -F FORWARDFor my surprise the data flow (observed with tcpdump) is still there! It is like the state machine does not let go this data flow.
What to do to block this data flow??
Is there any way to flush the conntrack database?Regards
--
Ethy H. Brito /"\
InterNexo Ltda. \ / CAMPANHA DA FITA ASCII - CONTRA MAIL HTML
+55 (12) 3941-6860 X ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
S.J.Campos - Brasil / \
_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
Signature · 12 lines
Ethy H. Brito /"\ InterNexo Ltda. \ / CAMPANHA DA FITA ASCII - CONTRA MAIL HTML +55 (12) 3941-6860 X ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL S.J.Campos - Brasil / \ _______________________________________________ LARTC mailing list [email protected] http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc _______________________________________________ LARTC mailing list [email protected] http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
Quoted 4 lines · On Thu, 26 Jan 2006 08:58:34 -0600 "Greg Scott"…
No, it just flushes the rules and changes the policy to ACCEPT. The connections are still connected. I do this all the time with firewalls up and running. If flushing the rules killed all the active connections, it would be super disruptive.
Well, at least the coneections belonging to NAT should be destroyed because there is no authorization to these data flow anymore. Don't you agree?
Quoted 3 lines
I suppose if you want to stop connections, flush the rules and then set the policy to DROP - do 2 commands instead of just flushing.
I did this. Stoped (flushed) all (I really mean all) rules and started them again with a diferent source adderss for NAT rules. My surprise was that that old NAT connection continued to flow despite the fact there was no rule at NAT filter for it. I suppose this old connection is still flowing because conntrack database state it as ESTABLISHED and it is grabbed by "ESTABLISHED, RELATED -j ACCEPT" rule. Did I made myself clear?
I suppose that once a data flow is establisehd its conntrack database entry is only deleted if you or the other party kills the applications tha holds the connetions alive.
BTW rebooting the machine stops the old data flow and only accepts the second (new) one. (unnecessary to say that rebooting clears the conntrack database, of course).
Quoted 3 lines
Take what I say for what it's worth. I am not a netfilter developer, just a long-time user.
And so am I. Just a long-time user since ipfwadm.
(Any developer reading this could please shed some like on this?)
Ethy
_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
Quoted 3 lines
Well, at least the coneections belonging to NAT should be destroyed because there is no authorization to these data flow anymore. Don't you agree?
Don't know. The Netfilter developers would have to answer that one. The netfilter guys have a userspace conntrack program that (I think) lets look at the conntrack database. And I think there are some data structures in the /proc filesystem. But I haven't dug into them.
- Greg
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ethy H. Brito
Sent: Thursday, January 26, 2006 9:16 AM
Cc: [email protected]
Subject: Re: [LARTC] nat table remenbering nat's
Quoted 5 lines · On Thu, 26 Jan 2006 08:58:34 -0600 "Greg Scott"…
No, it just flushes the rules and changes the policy to ACCEPT. The connections are still connected. I do this all the time with firewalls up and running. If flushing the rules killed all the active
connections, it would be super disruptive.
Well, at least the coneections belonging to NAT should be destroyed because there is no authorization to these data flow anymore. Don't you agree?
Quoted 3 lines
I suppose if you want to stop connections, flush the rules and then set the policy to DROP - do 2 commands instead of just flushing.
I did this. Stoped (flushed) all (I really mean all) rules and started them again with a diferent source adderss for NAT rules. My surprise was that that old NAT connection continued to flow despite the fact there was no rule at NAT filter for it. I suppose this old connection is still flowing because conntrack database state it as ESTABLISHED and it is grabbed by "ESTABLISHED, RELATED -j ACCEPT" rule. Did I made myself clear?
I suppose that once a data flow is establisehd its conntrack database entry is only deleted if you or the other party kills the applications tha holds the connetions alive.
BTW rebooting the machine stops the old data flow and only accepts the second (new) one.
(unnecessary to say that rebooting clears the conntrack database, of course).
Quoted 3 lines
Take what I say for what it's worth. I am not a netfilter developer, just a long-time user.
And so am I. Just a long-time user since ipfwadm.
(Any developer reading this could please shed some like on this?)
Ethy
_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
To clear things up:
Connection which was up was not blocked in FORWARD?
You only changed rule in PREROUTING ("...different source adress...")? If so, "old" connection just didn't hit prerouting as its already been there, and forward isn't dropping its packets.
To me it seems to behave as expected.
Quoted 7 lines · Ethy H. Brito
On Thu, 26 Jan 2006 08:58:34 -0600
I did this. Stoped (flushed) all (I really mean all) rules and started them again with a diferent source adderss for NAT rules. My surprise was that that old NAT connection continued to flow despite the fact there was no rule at NAT filter for it. I suppose this old connection is still flowing because conntrack database state it as ESTABLISHED and it is grabbed by "ESTABLISHED, RELATED -j ACCEPT" rule. Did I made myself clear?
_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
Quoted 2 lines · On Thu, 26 Jan 2006 21:10:00 +0200 Tomas Simonaitis <[email protected]> wrote:
To clear things up:
Connection which was up was not blocked in FORWARD?
No, they are not. I have a ESTABLISHED -j ACCEPT rule as first rule.
Quoted 1 line
You only changed rule in PREROUTING ("...different source adress...")?
That is correct.
Quoted 3 lines
If so, "old" connection just didn't hit prerouting as its already been there, and forward isn't dropping its packets.
To me it seems to behave as expected.
Questionable. I flushed NAT. I assume that a flushed table must forget each and every previous authorizations. The way you put it, the only way to stop old stream is to reboot the machine which is unacceptable from my point of view.
Suppose you have a partnership and want to drop those privileges. While your late partner does not close the connction(s) (s)he will still have granted access to your intranet. Did you think of that?
Ethy
_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
You might want to take a look at cutter (http://www.lowth.com/cutter/)
(maybe as temporary solution, at least you wouldn't need to reboot).
Quoted 10 lines · Ethy H. Brito
Questionable. I flushed NAT. I assume that a flushed table must forget each and every previous authorizations. The way you put it, the only way to stop old stream is to reboot the machine which is unacceptable from my point of view.
Suppose you have a partnership and want to drop those privileges. While your late partner does not close the connction(s) (s)he will still have granted access to your intranet. Did you think of that?
Ethy
_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc