workaround for no DROP in table nat ?
Hi list,
Recent versions of iptables have forbidden the use of DROP in the nat table. I can't understand, however, how one is supposed to work around this limitation: is there a howto or some kind of documentation somewhere which explains how to deal with this change?
Suppose my current rules look something like this:
-t nat -A OUTPUT -p tcp -d somenetwork -m tcp --syn --dport 80 -j CONTROLLED
-t nat -A CONTROLLED -m limit --limit 10/hour -j RETURN
-t nat -A CONTROLLED -p tcp -m statistic --mode random --probability 0.1 -j REDIRECT --to-ports 80 -t nat -A CONTROLLED -j DROP
In other words, the point is that connections which are outbound to somenetwork should be dropped beyond a certain rate, except for a small portion of them which should be redirected to a local port for capturing.
I'm confused about what I should do to achieve the same effect under the modified rules. I can't put the whole thing in the filter table because of the REDIRECT: but now I also can't put the whole thing in the nat table because of the DROP. I also fail to see how I can split the rules across tables (if I replace -j DROP by -j RETURN in nat and then replicate the limit check in the filter table, I'm afraid the latter might not stay synchronized with the one in the nat table).
If the nat table is not allowed to just drop a packet, would it be possible to have a -j MUSTBEDROPPEDINFILTERTABLE or something of the sort, which ensures that the filter table will necessarily drop that packet? This would be a convenient workaround for the new limitation (cleaner than, say, redirecting the packet to some absurd port and then dropping on that port).
Any suggestions?
Happy hacking,
Signature · 2 lines
David A. Madore ( http://www.madore.org/~david/ )
OoO Lors de la soirée naissante du lundi 15 juin 2009, vers 18:59, David Madore <[email protected]> disait :
Review
Quoted 11 lines
Recent versions of iptables have forbidden the use of DROP in the nat table. I can't understand, however, how one is supposed to work around this limitation: is there a howto or some kind of documentation somewhere which explains how to deal with this change?
Suppose my current rules look something like this:
(quoted diff) +0
-4-t nat -A OUTPUT -p tcp -d somenetwork -m tcp --syn --dport 80 -j CONTROLLED -t nat -A CONTROLLED -m limit --limit 10/hour -j RETURN -t nat -A CONTROLLED -p tcp -m statistic --mode random --probability 0.1 -j REDIRECT --to-ports 80 -t nat -A CONTROLLED -j DROP
You can DROP in the mangle table instead.
-t mangle -A OUTPUT -p tcp -d ... -j CONTROLLED
-t mangle -j CONTROLLED -m limit --limit ... -j RETURN
-t mangle -j CONTROLLED -p tcp -m statistic --mode random --probability 0.9 -j DROP -t mangle -j CONTROLLED -j MARK --set-mark 1
-t nat -A OUTPUT -m mark --mark 1 -j REDIRECT --to-ports 80
You can also DROP in the raw table, but I think you cannot set a mark here.
Signature · 2 lines
BOFH excuse #381: Robotic tape changer mistook operator's tie for a backup tape.
Quoted 19 lines · Vincent Bernat
OoO Lors de la soirée naissante du lundi 15 juin 2009, vers 18:59, David Madore <[email protected]> disait :
Review
Quoted 13 lines
Recent versions of iptables have forbidden the use of DROP in the nat table. I can't understand, however, how one is supposed to work around this limitation: is there a howto or some kind of documentation somewhere which explains how to deal with this change?
Suppose my current rules look something like this:
-t nat -A OUTPUT -p tcp -d somenetwork -m tcp --syn --dport 80 -j CONTROLLED
(quoted diff) +0
-4-t nat -A CONTROLLED -m limit --limit 10/hour -j RETURN -t nat -A CONTROLLED -p tcp -m statistic --mode random --probability 0.1 -j REDIRECT --to-ports 80 -t nat -A CONTROLLED -j DROPYou can DROP in the mangle table instead.
Review
Quoted 3 lines
(quoted diff) +0
-3-t mangle -A OUTPUT -p tcp -d ... -j CONTROLLED -t mangle -j CONTROLLED -m limit --limit ... -j RETURN -t mangle -j CONTROLLED -p tcp -m statistic --mode random --probability
0.9
Quoted 6 lines
(quoted diff) +0
-3-j DROP -t mangle -j CONTROLLED -j MARK --set-mark 1 -t nat -A OUTPUT -m mark --mark 1 -j REDIRECT --to-ports 80You can also DROP in the raw table, but I think you cannot set a mark here.
Would this not begin to drop n% packets instead of n% connections? due to the nat table only receiving NEW packets and mangle receiving all.
I think you may also need to add state NEW to the rule somehow.
AYJ
В Вто, 16/06/2009 в 16:29 +1200, Amos Jeffries пишет:
Quoted 28 lines · Vincent Bernat
Quoted 19 lines
OoO Lors de la soirée naissante du lundi 15 juin 2009, vers 18:59, David Madore <[email protected]> disait :
Review
Quoted 13 lines
Recent versions of iptables have forbidden the use of DROP in the nat table. I can't understand, however, how one is supposed to work around this limitation: is there a howto or some kind of documentation somewhere which explains how to deal with this change?
Suppose my current rules look something like this:
-t nat -A OUTPUT -p tcp -d somenetwork -m tcp --syn --dport 80 -j CONTROLLED
(quoted diff) +0
-4-t nat -A CONTROLLED -m limit --limit 10/hour -j RETURN -t nat -A CONTROLLED -p tcp -m statistic --mode random --probability 0.1 -j REDIRECT --to-ports 80 -t nat -A CONTROLLED -j DROPYou can DROP in the mangle table instead.
Review
Quoted 3 lines
(quoted diff) +0
-3-t mangle -A OUTPUT -p tcp -d ... -j CONTROLLED -t mangle -j CONTROLLED -m limit --limit ... -j RETURN -t mangle -j CONTROLLED -p tcp -m statistic --mode random --probability0.9
Quoted 4 lines
(quoted diff) +0
-3-j DROP -t mangle -j CONTROLLED -j MARK --set-mark 1 -t nat -A OUTPUT -m mark --mark 1 -j REDIRECT --to-ports 80
Quoted 7 lines
Quoted 2 lines
You can also DROP in the raw table, but I think you cannot set a mark here.
Would this not begin to drop n% packets instead of n% connections? due to the nat table only receiving NEW packets and mangle receiving all.
I think you may also need to add state NEW to the rule somehow.
Anyways, what is the reason for a such big change?
Signature · 1 line
Покотиленко Костик <[email protected]>