Lonely Dreamer (sanmai) wrote,
Lonely Dreamer
sanmai

DDoS Vs. iptables

Отсекаем DDoS по 80-му порту на уровне iptables:
iptables -I INPUT -p tcp --dport 80 -m string --string "Host: www.example.com" \
--algo bm --to 1024 -m comment --comment "www.example.com" -j DROP
Потом так:
ipset -N ddos iphash

grep DD/Mmm/YY:HH access_log | cut -d" " -f 1 | sort | uniq > bad_ips
for i in `cat bad_ips`; do ipset -A ddos $i; done;

ipset -S ddos > ddos.ipset

iptables -I INPUT -p tcp -m tcp --dport 80 -m set --set ddos src -j DROP
Проверка чтобы ничего не пролезало:
iptables -R INPUT 2 -p tcp  --dport 80 -m string --string "Host: www.example.com" \
--algo bm -m limit --limit 10/min -j LOG
Потом по необходимости:
ipset -A ddos IP
Tags: ddos, iptables, linux, useful
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 2 comments