2012年06月28日 Setting sample for iptables against DDoS to http [長年日記]
_ Setting sample for iptables against DDoS to http
/usr/sbin/iptables -F /usr/sbin/iptables -P INPUT DROP /usr/sbin/iptables -A INPUT -p tcp ! --syn -m state --state ESTABLISHED,RELATED -j ACCEPT /usr/sbin/iptables -A INPUT -p tcp --dport 80 \ -m hashlimit \ --hashlimit-name http \ --hashlimit 5/s \ --hashlimit-burst 50 \ --hashlimit-mode srcip,dstport \ --hashlimit-htable-expire 10000 \ -j ACCEPT /usr/sbin/iptables -A INPUT -p all -i eth0 -j DROP
- -m hashlimit : load module for hashlimit
- --hashlimit-name http : hash table name. In this case, you can see /proc/net/ipt_hashlimit/http for statistics
- --hashlimit 5/s : connection is limited to 5 times per second
- --hashlimit-burst 50 : connection count for trigger to hashlimit
- --hashlimit-mode srcip,dstport : connection count unit(combination of srcip,dstip,srcport,dstport)
- --hashlimit-htable-expire 10000 : life time for hash table(mil sec)