Skip to content

Instantly share code, notes, and snippets.

@fangdingjun
Last active November 27, 2015 07:03
Show Gist options
  • Save fangdingjun/45786e235be05fc8a780 to your computer and use it in GitHub Desktop.
Save fangdingjun/45786e235be05fc8a780 to your computer and use it in GitHub Desktop.
使用iptables防止webbench工具的攻击
#限制单个ip的tcp的并发连接数为30
iptables -A INPUT -p tcp -m connlimit --connlimit-above 30 -j DROP
#限制连接web服务的连接速度, 单个ip在10s内只允许建立10个新连接
iptables -A INPUT -p tcp -m multiport --dport 80,443 -m state --state NEW --set --name web
iptables -A INPUT -p tcp -m multiport --dport 80,443 -m state --state NEW --update --name web \
--hitcount 10 --seconds 10 -j REJECT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment