DDOS - как быстро заблокировать IP адреса через tail/iptables/csf, с которых идет ДДОС атака: различия между версиями

Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2023
Перейти к:навигация, поиск
Строка 3: Строка 3:
 
Блокируем через цикл for + tail + csf:
 
Блокируем через цикл for + tail + csf:
 
  # for i in `tail -n1000 /var/www/user1/data/logs/site.info.access.log | grep "python-requests/2.13.0" | awk {'print $1'} | sort | uniq -c | sort -n | awk {'print $2'}` ; do { csf -d $i; }; done;
 
  # for i in `tail -n1000 /var/www/user1/data/logs/site.info.access.log | grep "python-requests/2.13.0" | awk {'print $1'} | sort | uniq -c | sort -n | awk {'print $2'}` ; do { csf -d $i; }; done;
 +
 +
Еще быстрее:
 +
# tail -n100000 /var/www/user1/data/logs/site.info.access.log | grep "python-requests/2.13.0" | awk {'print $1'} | sort | uniq -c | sort -n | awk {'print $2'} > /etc/csf/csf.deny && csf -r
 +
  
 
тоже самое, но для iptables:
 
тоже самое, но для iptables:
 
  for i in `tail -n1000 /var/log/nginx/access.log | grep "host:site.market" | awk {'print $1'} | sort | uniq -c | sort -n | awk {'print $2'}` ; do { iptables -I INPUT -s $i -j DROP; }; done;
 
  for i in `tail -n1000 /var/log/nginx/access.log | grep "host:site.market" | awk {'print $1'} | sort | uniq -c | sort -n | awk {'print $2'}` ; do { iptables -I INPUT -s $i -j DROP; }; done;

Версия 09:45, 25 сентября 2022

DDOS - как быстро заблокировать IP адреса через tail/iptables/csf, с которых идет ДДОС атака

Блокируем через цикл for + tail + csf:

# for i in `tail -n1000 /var/www/user1/data/logs/site.info.access.log | grep "python-requests/2.13.0" | awk {'print $1'} | sort | uniq -c | sort -n | awk {'print $2'}` ; do { csf -d $i; }; done;

Еще быстрее:

# tail -n100000 /var/www/user1/data/logs/site.info.access.log | grep "python-requests/2.13.0" | awk {'print $1'} | sort | uniq -c | sort -n | awk {'print $2'} > /etc/csf/csf.deny && csf -r


тоже самое, но для iptables:

for i in `tail -n1000 /var/log/nginx/access.log | grep "host:site.market" | awk {'print $1'} | sort | uniq -c | sort -n | awk {'print $2'}` ; do { iptables -I INPUT -s $i -j DROP; }; done;