iptables+ipset
fame 5 февраля, 2013 - 01:26
Господа, требуеть ваша помощь с связкой iptables + ipset.
Сам скрипт:
#!/bin/sh ### Скрипт конфигурации IPTables ### #--------------СЕРВЕР------------ # Очищаем предыдущие записи iptables -F iptables -X # Разрешаем локальный интерфейс iptables -A INPUT -i lo -j ACCEPT iptables -A OUTPUT -o lo -j ACCEPT # Даем доступ в интернет (established and out) iptables -A OUTPUT -o eth0 -j ACCEPT iptables -A INPUT -i eth0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT # Простая защита от DoS-атаки iptables -A INPUT -p tcp -m tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT # Открываем порты iptables -A INPUT -p udp -m multiport --dports 27015:29015,3784,6100,9987,64738 -j ACCEPT iptables -A INPUT -p tcp -m multiport --dports 21,22,10011,3784,30033 -j ACCEPT # Защита от спуфинга iptables -I INPUT -m conntrack --ctstate NEW,INVALID -p tcp --tcp-flags SYN,ACK SYN,ACK -j REJECT --reject-with tcp-reset # Защита от попытки открыть входящее соединение TCP не через SYN iptables -I INPUT -m conntrack --ctstate NEW -p tcp ! --syn -j DROP # Закрываемся от кривого icmp iptables -I INPUT -p icmp -f -j DROP # Разрешение главных типов протокола ICMP iptables -A INPUT -p icmp --icmp-type 3 -j ACCEPT iptables -A INPUT -p icmp --icmp-type 11 -j ACCEPT iptables -A INPUT -p icmp --icmp-type 12 -j ACCEPT # Защита сервера SSH от брутфорса iptables -I INPUT -p tcp --dport 22 -i eth0 -m conntrack --ctstate NEW -m recent --set iptables -I INPUT -p tcp --dport 22 -i eth0 -m conntrack --ctstate NEW -m recent --update --seconds 60 --hitcount 4 -j DROP # Security of Jo's v2 exploit iptables -A INPUT -p udp -m udp -m string --hex-string "|a090909090909090901809a5000000|" --algo kmp -j DROP # Security of new INPUT flooder/doser [v1.0-v1.1] iptables -A INPUT -p udp -m udp -m string --hex-string "|d50000806e000000|" --algo kmp -m limit --limit 25/minute --limit-burst 1 -j LOG --log-prefix " [FLOOD] [14.03.2012]: " iptables -A INPUT -p udp -m udp -m string --hex-string "|d50000806e000000|" --algo kmp -j DROP iptables -A INPUT -p udp -m udp -m string --hex-string "|d51000806e000000|" --algo kmp -m limit --limit 25/minute --limit-burst 1 -j LOG --log-prefix " [FLOOD] [19.03.2012]: " iptables -A INPUT -p udp -m udp -m string --hex-string "|d51000806e000000|" --algo kmp -j DROP # Security of hlbrute iptables -A INPUT -p udp -m udp -m string --hex-string "|484C4272757465|" --algo kmp -j DROP # Security of any rcon actions!!! iptables -A INPUT -p udp -m udp -m string --hex-string "|72636F6E|" --algo kmp -j DROP # Accept any connect packets (steam > 500bytes) iptables -A INPUT -p udp -m udp -m string --hex-string "|636f6e6e656374|" --algo kmp -j ACCEPT # Limit Packets length iptables -A INPUT -p udp -m udp -m length --length 1:1250 -j ACCEPT iptables -A INPUT -p udp -m udp -m limit --limit 25/minute --limit-burst 1 -j LOG --log-prefix " [FLOOD] [BIGGEST PACKET]: " iptables -A INPUT -p udp -m udp -j DROP # Security from mass IP iptables -A INPUT -p udp -m udp -m string --hex-string "|FFFFFFFF56|" --algo kmp -j DROP # Security of INPUTFlood iptables -A INPUT -p udp -m udp -m string --hex-string "|17c74a30a2fb752396b63532b1bf79b0|" --algo kmp -j DROP iptables -A INPUT -p udp -m udp -m string --hex-string "|17951a20e2ab6d63d6ac7d62f1f721e057cd4270e2f1357396f66522f1ed61f0|" --algo kmp -j DROP iptables -A INPUT -p udp -m udp -m string --hex-string "|178f5230e2e17d73d6bc6562f1ed29e0|" --algo kmp -j DROP iptables -A INPUT -p udp -m udp -m string --hex-string "|d50000806e000000|" --algo kmp -j DROP iptables -A INPUT -p udp -m udp -m string --hex-string "|ffffffff6765746368616c6c656e6765000000000000|" --algo kmp -j DROP # Security for TF2 Flood iptables -A INPUT -p udp -m udp -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT iptables -A INPUT -p udp -m conntrack --ctstate NEW -m hashlimit --hashlimit 100/s --hashlimit-burst 100 --hashlimit-mode srcip --hashlimit-name TF -j ACCEPT iptables -A INPUT -p udp -j DROP # Security for CS:S Flood iptables -A INPUT -p udp -m hashlimit --hashlimit-upto 101/s --hashlimit-mode srcip --hashlimit-name css -j ACCEPT iptables -A INPUT -p udp -j DROP iptables -A INPUT -p udp -m length --length 28 -j DROP # Security for CS:S Socket ProcessAccept Error iptables -A INPUT -p tcp --syn -m connlimit --connlimit-above 10 -j DROP # Drop DOS exploit packages for SRCDS games iptables -A INPUT -p udp -m udp -m string --algo bm --hex-string '|ffffffff54|' -m limit --limit 1/s --limit-burst 1 -j ACCEPT iptables -A INPUT -p udp -m udp -m string --algo bm --hex-string '|ffffffff54|' -j DROP iptables -A INPUT -p udp -m udp -m string --algo bm --hex-string '|ffffffff55|' -m limit --limit 1/s --limit-burst 1 -j ACCEPT iptables -A INPUT -p udp -m udp -m string --algo bm --hex-string '|ffffffff55|' -j DROP iptables -A INPUT -p udp -m udp -m string --algo bm --hex-string '|ffffffff56|' -m limit --limit 1/s --limit-burst 1 -j ACCEPT iptables -A INPUT -p udp -m udp -m string --algo bm --hex-string '|ffffffff56|' -j DROP iptables -A INPUT -p udp -m udp -m string --algo bm --hex-string '|ffffffff57|' -m limit --limit 1/s --limit-burst 1 -j ACCEPT iptables -A INPUT -p udp -m udp -m string --algo bm --hex-string '|ffffffff57|' -j DROP
»
- Для комментирования войдите или зарегистрируйтесь

И где вопрос ?
И где вопрос ?
Compute:
Bosch M2.8.1 -> custom Bosch M2.8.3 clone from Russia.
Speed about 260 km,Ram 2 pers.,HDD - 70 kg,210 FLOPS ;)
Вопрос, как их подружить.
Вопрос, как их подружить.
??? :)
??? :)
А где же история ваших проб и ошибок?.. ;)
Иначе вам в "Разовые работы"...
Читал мануалы, но не как не
Читал мануалы, но не как не доходит где какой тип использовать, и как правильно записывать)
Буду благодарен каким нибудь примером ;)
невозможно ответить на
невозможно ответить на вопрос, которого по сути нет, не так ли?
fame написал(а):Читал
я подозреваю, что ты даже не открывал ман.
Мне не жалко - примерно так -m set "SET NAME" или -j SET
для чукчей-нечитателей:
SET This module adds and/or deletes entries from IP sets which can be defined by ipset(8). --add-set setname flag[,flag...] add the address(es)/port(s) of the packet to the set --del-set setname flag[,flag...] delete the address(es)/port(s) of the packet from the set where flag(s) are src and/or dst specifications and there can be no more than six of them. --timeout value when adding an entry, the timeout value to use instead of the default one from the set definition --exist when adding an entry if it already exists, reset the timeout value to the specified one or to the default from the set definition Use of -j SET requires that ipset kernel support is provided, which, for standard kernels, is the case since Linux 2.6.39. ............ set This module matches IP sets which can be defined by ipset(8). [!] --match-set setname flag[,flag]... where flags are the comma separated list of src and/or dst specifications and there can be no more than six of them. Hence the command iptables -A FORWARD -m set --match-set test src,dst will match packets, for which (if the set type is ipportmap) the source address and destination port pair can be found in the specified set. If the set type of the specified set is single dimension (for example ipmap), then the command will match packets for which the source address can be found in the specified set. --return--nomatch If the --return--nomatch option is specified and the set type supports the nomatch flag, then the matching is reversed: a match with an element flagged with nomatch returns true, while a match with a plain element returns false. The option --match-set can be replaced by --set if that does not clash with an option of other extensions. Use of -m set requires that ipset kernel support is provided, which, for standard kernels, is the case since Linux 2.6.39.Дальше или код, или в Работу
Compute:
Bosch M2.8.1 -> custom Bosch M2.8.3 clone from Russia.
Speed about 260 km,Ram 2 pers.,HDD - 70 kg,210 FLOPS ;)