Показать сообщение отдельно
Непрочитано 04.08.2010, 23:48   #8
Пользователь

По умолчанию Re: Настройка защиты от ддос

Настройка системы это хорошо, но если стоит хороший сервер на *nux и канал 100мб. от 200 ботов может спасти iptables, конечно не является панацеей, но от школьников и середнячков может спасти. Причем хорошее дополнение к любому антиddos приложению. Принцип построен на блоке навязчивых ip-адресов, чем больше пакетов, тем дольше блок. Sprut и т.п. начинает ложить свой канал. Данные парамметры проверялось на исходящем гигабитном канале, входящий 100мб.

Код:
iptables -F
iptables -t nat -F
iptables -X

iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT

sysctl net.netfilter.nf_conntrack_acct=1

iptables -A INPUT -s *.*.*.* -j ACCEPT
iptables -A INPUT -s *.*.*.*/* -j ACCEPT
iptables -A INPUT -s *.*.*.*/* -j ACCEPT
iptables -A INPUT -s *.*.*.*/* -j ACCEPT
iptables -A INPUT -s *.*.*.* -j ACCEPT
iptables -A INPUT -s *.*.*.* -j ACCEPT
iptables -A INPUT -p TCP -s 0/0 --dport **** -j DROP      //прикрываемые порты
iptables -A INPUT -p TCP -s 0/0 --dport **** -j DROP       //прикрываемые порты

iptables -N LOGIN
iptables -N LOGIN_REJECT_1
iptables -N LOGIN_REJECT_2

iptables -A INPUT -p tcp --dport *** -m state --state NEW -j LOGIN      //правило для парта

iptables -A LOGIN -m recent --update --name LOGIN_REJECT_1 --seconds    600 --hitcount 1 -j DROP
iptables -A LOGIN -m recent --update --name LOGIN_REJECT_2 --seconds   3600 --hitcount 1 -j DROP

iptables -A LOGIN -m recent --set --name LOGIN_c1
iptables -A LOGIN -m recent --set --name LOGIN_c2

iptables -A LOGIN -m recent --update --name LOGIN_c1 --seconds    60 --hitcount  10 -j LOGIN_REJECT_1
iptables -A LOGIN -m recent --update --name LOGIN_c2 --seconds   600 --hitcount  20 -j LOGIN_REJECT_2

iptables -A LOGIN -m limit --limit 1/sec --limit-burst 3 -j ACCEPT

iptables -A LOGIN -j REJECT

iptables -A LOGIN_REJECT_1 -m recent --set --name LOGIN_REJECT_1
iptables -A LOGIN_REJECT_1 -j LOG --log-prefix "INPUT LOGIN REJECT: (10min)"
iptables -A LOGIN_REJECT_1 -j REJECT

iptables -A LOGIN_REJECT_2 -m recent --set --name LOGIN_REJECT_2
iptables -A LOGIN_REJECT_2 -j LOG --log-prefix "INPUT LOGIN REJECT: (1hour)"
iptables -A LOGIN_REJECT_2 -j REJECT

iptables -N HTTP
iptables -N HTTP_REJECT_1

iptables -A INPUT -p tcp --dport **** -m state --state NEW -j HTTP

iptables -A HTTP -m recent --update --name HTTP_REJECT_1 --seconds    60 --hitcount 10 -j DROP

iptables -A HTTP -m recent --set --name HTTP_c1

iptables -A HTTP -m recent --update --name HTTP_c1 --seconds    60 --hitcount  20 -j HTTP_REJECT_1

iptables -A HTTP -m limit --limit 10/sec --limit-burst 30 -j ACCEPT

iptables -A HTTP -j REJECT

iptables -A HTTP_REJECT_1 -m recent --set --name HTTP_REJECT_1
iptables -A HTTP_REJECT_1 -j LOG --log-prefix "INPUT HTTP REJECT: (1min)"
iptables -A HTTP_REJECT_1 -j REJECT
Что как куда, пробитые линуксойды поймут, остальным курить iptables.
Совесть вне форума Ответить с цитированием
Сказали спасибо: