I am working on a script which icludes limit number of connection outbounnd connection. but the script executes but does not limit any connection as i expected
`####### Connection Rate Limiting ###########
NEW,ESTABLISHED,RELATED
for host in $HwHPOT; do
TCP Rate Limiting
iptables -A FORWARD -p tcp -m physdev –physdev-in ${HwIN} -m state –state NEW -m limit –limit ${TCPRATE}/${TIMESCALE} –limit-burst ${TCPRATE} -s ${host} -j TCPChain
iptables -A FORWARD -p tcp -m physdev –physdev-in ${HwIN} -m state –state NEW -m limit –limit 1/${TIMESCALE} –limit-burst 1 -s ${host} -j LOG –log-level 4 –log-prefix “DROP:TCP > ${TCPRATE} Limit “
iptables -A FORWARD -p tcp -m physdev –physdev-in ${HwIN} -m state –state NEW -s ${host} -j DROP
UDP Rate Limiting
iptables -A FORWARD -p udp -m physdev –physdev-in ${HwIN} -m state –state NEW -m limit –limit ${UDPRATE}/${TIMESCALE} –limit-burst ${UDPRATE} -s ${host} -j UDPChain
iptables -A FORWARD -p udp -m physdev –physdev-in ${HwIN} -m state –state NEW -m limit –limit 1/${TIMESCALE} –limit-burst 1 -s ${host} -j LOG –log-level 4 –log-prefix “DROP:UDP > ${UDPRATE} Limit “
iptables -A FORWARD -p udp -m physdev –physdev-in ${HwIN} -m state –state NEW -s ${host} -j DROP
ICMP rate Limiting
#iptables -A FORWARD -p icmp -m physdev –physdev-in ${HwIN} -m state –state NEW,ESTABLISHED -m limit –limit ${ICMPRATE}/${TIMESCALE} –limit-burst ${ICMPRATE} -s ${host} -j ICMPChain
#iptables -A FORWARD -p icmp -m physdev –physdev-in ${HwIN} -m state –state NEW,ESTABLISHED -m limit –limit 1/${TIMESCALE} –limit-burst 1 -s ${host} -j LOG –log-level 4 –log-prefix “DROP:ICMP > ${ICMPRATE} Limit “
#iptables -A FORWARD -p icmp -m physdev –physdev-in ${HwIN} -m state –state NEW,ESTABLISHED -s ${host} -j DROP
ICMP rate limiting
iptables -A FORWARD -p icmp –icmp-type 8 -m physdev –physdev-in ${HwIN} -m state –state NEW,ESTABLISHED,RELATED -m limit –limit ${ICMPRATE}/${TIMESCALE} –limit-burst ${ICMPRATE} -s ${host} -j ICMPChain
iptables -A FORWARD -p icmp –icmp-type 8 -m physdev –physdev-in ${HwIN} -m state –state NEW,ESTABLISHED,RELATED -m limit –limit 1/${TIMESCALE} –limit-burst 1 -s ${host} -j LOG –log-level 4 –log-prefix “DROP:ICMP > ${ICMPRATE} Limit “
iptables -A FORWARD -p icmp –icmp-type 8 -m physdev –physdev-in ${HwIN} -m state –state NEW,ESTABLISHED,RELATED -s ${host} -j DROP
Other Limiting
iptables -A FORWARD -m physdev –physdev-in ${HwIN} -m state –state NEW -m limit –limit ${OTHERRATE}/${TIMESCALE} –limit-burst ${OTHERRATE} -s ${host} -j OtherChain
iptables -A FORWARD -m physdev –physdev-in ${HwIN} -m state –state NEW -m limit –limit 1/hour –limit-burst 1 -s ${host} -j LOG –log-level 4 –log-prefix “DROP:Other Rate > ${TCPRATE} Limit “
#iptables -A FORWARD -m physdev –physdev-in ${HwIN} -m state –state NEW,RELATED -s ${host} -j DROP
#iptables -A FORWARD -m state –state ESTABLISHED -s ${host} -j ACCEPT
done
}`
Can Anyone help me to make my limiting work as it drops connection as i ping from one ip to my target ip after 10 it drop packets or not more than 10 packets. The above code is part of a script .
Anuj Sharma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.