Tuesday, September 16, 2008

Find n block IPs with max connections

SSH to the server and run The following command to see the IPs with most concurrent connections:

/bin/netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n |more

Block un-wanted IPs using IPTables

/sbin/iptables -I INPUT -s 12.34.56.78 -j DROP
/sbin/service iptables save
/sbin/service iptables restart

No comments: