Sample Header Ad - 728x90

IPTables to limit high "Call-Per-Second" and redirect to another program (same machine)

1 vote
1 answer
654 views

I'm looking for a way to "control" high volume of SIP VoIP INVITEs (UDP) per second (Call Per Seconds) at iptables level in my VoIP server reaching port 5060.
What i need to do is limit amount of INVITE's per second to a certain rate (for example 20 cps), if i receive a high volume of CPS to the server, i need to redirect them to another port (for example UDP/5090) in the same machine where another program is runnig, to answer them with SIP message "603 Decline". Is this possible?
So far i'm a little bit lost with a lot of answers to similar questions... do i need to use --limit?, connlimit?, hitcount??...
Along with this, is possible to do this by source ip address?
Conceptually I was thinking something like this... if is possible:
INPUT iptables --append INPUT --match conntrack --ctstate NEW --jump RATE-LIMIT RATE-LIMIT iptables --append RATE-LIMIT --match limit --limit 20/sec --limit-burst 20 --jump ACCEPT iptables --append RATE-LIMIT --jump DECLINE-INVITE DECLINE-INVITE iptables --append DECLINE-INVITE [how to redirect to port udp 5090] Thanks! Ricardo
Asked by Ricardo (11 rep)
May 3, 2021, 08:02 PM
Last activity: May 3, 2021, 10:26 PM