netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PREROUTING in nat table isn't working as aspected
@ 2014-02-10 12:52 Theo Belder
  2014-02-10 15:48 ` Phil Oester
  0 siblings, 1 reply; 2+ messages in thread
From: Theo Belder @ 2014-02-10 12:52 UTC (permalink / raw)
  To: netfilter

We have sometimes a problem with SIP brute force attacks, and consumes
all the available bandwidth. The attacker keeps sending SIP REGISTER
messages, even they don't get a response.
What I'm trying to do is to redirect the traffic to an alternative port
which will respond with a message so the attack assumes they have a
valid registration and stops the attack. Redirecting is necessary
because the service on the original port should not be interrupted.

The following rule I've added to iptables:
iptables -t nat -A PREROUTING -s 222.186.29.98 -p udp --dport 5060 -j
REDIRECT --to-port 5050

But after inserting (and restarting iptables), the packets were not
redirected to port 5050.
My guess was it has something to do with the ip_conntrack module, so I
inserted the following rules in iptables:
iptables -t raw -A PREROUTING -s 222.186.29.98 -p udp --dport 5060 -j
NOTRACK
iptables -t raw -A OUTPUT -d 222.186.29.98 -p udp --sport 5060 -j
NOTRACK

after 180 secs the conntrack table didn't mentioned the IP address
anymore (cat /proc/net/ip_conntrack | grep 222.186.29.98), but the
traffic was still not redirected. Still the packets were accepted by the
rule for accepting port 5060 (checked it with iptables -L -v)

So, I inserted a prerouting rule in the NAT table for a different IP
address (one of my own) and generated a UDP packet for port 5060. That
packet was redirected immediately to port 5050. So the redirect table
works for new connections. But for continuous existing traffic the
PREROUTING rule isn't working...

Do you have tips for redirecting traffic for an active traffic flood??

Best regards,
Theo





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PREROUTING in nat table isn't working as aspected
  2014-02-10 12:52 PREROUTING in nat table isn't working as aspected Theo Belder
@ 2014-02-10 15:48 ` Phil Oester
  0 siblings, 0 replies; 2+ messages in thread
From: Phil Oester @ 2014-02-10 15:48 UTC (permalink / raw)
  To: Theo Belder; +Cc: netfilter

On Mon, Feb 10, 2014 at 01:52:42PM +0100, Theo Belder wrote:
> ... So the redirect table
> works for new connections. But for continuous existing traffic the
> PREROUTING rule isn't working...

Exactly as expected.

> Do you have tips for redirecting traffic for an active traffic flood??

Clear the traffic from conntrack table by using the conntrack tool?  Then
the next packet which arrives WILL go through your PREROUTING rules.

Phil

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-10 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-10 12:52 PREROUTING in nat table isn't working as aspected Theo Belder
2014-02-10 15:48 ` Phil Oester

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).