By ahmerin
I have a following situation:
– I want certain source IPs to be natted to a different destination IP and Port. Following is how I am achieving it:
/usr/local/sbin/iptables -t nat -A PREROUTING -p tcp -s 192.168.10.12 –dport 1500 -j DNAT –to-destination 192.168.10.20:2000
Above runs on 192.168.10.12 and is working perfectly fine.
– Now, I want that if there are more than, say 20 packets per minute from source IP then further packets should be dropped.
Above is what I am having difficulty to achieve.
I have done the following but is not working:
/usr/local/sbin/iptables -t nat -A PREROUTING -p tcp -s 192.168.10.12 –dport 1500 -m limit –limit 20/m –limit-burst 5 -j DNAT –to-destination 192.168.10.20:2000
/usr/local/sbin/iptables -t nat -A PREROUTING -p tcp -s 192.168.10.12 –dport 1500 -j LOG –log-level 4 –log-prefix “192.168.10.12 Packet Limit exceeded: “
/usr/local/sbin/iptables -A INPUT -p tcp -s 192.168.10.12 –dport 1500 -j DROP
Can someone help me get the correct statement or confirm whether I can achieve the above requirement through IP tables.
Many thanks for your help.
Regards
Ahmerin