* [Comm] Re: Помогите разобраться с iptables @ 2004-05-29 17:16 ` Juveman 2004-05-30 1:40 ` Dmitry Lebkov 0 siblings, 1 reply; 2+ messages in thread From: Juveman @ 2004-05-29 17:16 UTC (permalink / raw) To: community > > lsmod самой первой строкой выводит: > > Module Size Used by > > ip_conntrack_ftp 71668 0 > > > > > > > > iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT > > > > Это правило у меня есть. Без него вообще ничего не загружается :)) > > > > > > > > > iptables -A INPUT -p TCP -m multiport --sport 21,80 -j ACCEPT > > > > > > iptables -A INPUT -p TCP -m multiport --sport 20,21,80 -j ACCEPT > > > > Так и сделал > > > > > > > > > iptables -A INPUT -p TCP -j REJECT > > > > > > Для использования функциональности этого модуля необходимо > > > задействовать правила с использованием модулья state и фильтровать > > > соответствующие состояния соединений. > > > > Это я понял. Насколько я понял из tutorial, если их не фильтровать, > > то вообще ничего не загрузится (политика по умолчанию для всех цепочек > > DROP). Поэтому это правило присутствует. Но именно фтп не работает. То > > есть клиент соединяется, проходит авторизацию и чего-то ждет. > > NAT или MASQUERADING используется? Выполни следующие команды: Нет, с этим пока не разбирался. И необходимости не было. > > # service iptables save > # cat /etc/sysconfig/iptables > > и результаты сюда. > Вот результаты: cat /etc/sysconfig/iptables # Generated by iptables-save v1.2.9 on Sat May 29 20:53:21 2004 *filter :INPUT DROP [2740:387783] :FORWARD DROP [0:0] :OUTPUT DROP [818:58417] [18:1392] -A INPUT -i lo -j ACCEPT [299:102114] -A INPUT -p tcp -m multiport --sports 20,21,80 -j ACCEPT [101:6102] -A INPUT -p tcp -j REJECT --reject-with icmp-port-unreachable [12:2981] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT [27545:1169439] -A OUTPUT -o lo -j ACCEPT [678:51062] -A OUTPUT -s 10.0.222.8 -j ACCEPT COMMIT # Completed on Sat May 29 20:53:21 2004 Я еще не закончил правила писать, просто несколько раз уже переписывал все. При таких правилах реально работает только браузер и ICQ :)) Хотя должен, насколько я понимаю, еще и FTP. Пробовал поставить правило -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT вторым в цепочке INPUT до блокирования соединений со всех портов кроме 20,21,80. Тогда работает вообще все (в том числе и фтп). Как будто запрета tcp соединений нет вообще. Если я правильно понимаю, все дело в очередности прохождения этих правил? То есть у меня пакет, который приходит с 21 порта принимается и уже не проводится проверка его состояния? Так что ли? В общем у меня пока получается либо разрешить нужные мне протоколы (но тогда фтп не работает), либо сделать так, чтобы фтп работало (но тогда не получается запретить соединения по ненужным мне протоколам). Как-нибудь можно добиться и того, и другого? :)) Может с цепочкой INPUT похимичить? :)) ---------- С уважением, Juveman ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Comm] Re: Помогите разобраться с iptables 2004-05-29 17:16 ` [Comm] Re: Помогите разобраться с iptables Juveman @ 2004-05-30 1:40 ` Dmitry Lebkov 0 siblings, 0 replies; 2+ messages in thread From: Dmitry Lebkov @ 2004-05-30 1:40 UTC (permalink / raw) To: community On Sat, 29 May 2004 21:16:30 +0400 Juveman <juveman@atom.ru> wrote: [skip] > > # service iptables save > > # cat /etc/sysconfig/iptables > > > > и результаты сюда. > > > Вот результаты: > cat /etc/sysconfig/iptables > # Generated by iptables-save v1.2.9 on Sat May 29 20:53:21 2004 > *filter > :INPUT DROP [2740:387783] > :FORWARD DROP [0:0] > :OUTPUT DROP [818:58417] > [18:1392] -A INPUT -i lo -j ACCEPT > [299:102114] -A INPUT -p tcp -m multiport --sports 20,21,80 -j ACCEPT > [101:6102] -A INPUT -p tcp -j REJECT --reject-with icmp-port-unreachable > [12:2981] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT > [27545:1169439] -A OUTPUT -o lo -j ACCEPT > [678:51062] -A OUTPUT -s 10.0.222.8 -j ACCEPT > COMMIT > # Completed on Sat May 29 20:53:21 2004 У тебя REJECT-правило, отвергающее все tcp-пакеты применяется раньше чем '-m state'. Приведи /etc/sysconfig/iptables вот к такому виду: # Generated by iptables-save v1.2.9 on Sat May 29 20:53:21 2004 *filter :INPUT DROP [0:0] :FORWARD DROP [0:0] :OUTPUT DROP [0:0] [0:0] -A INPUT -i lo -j ACCEPT [0:0] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT [0:0] -A INPUT -p tcp -m multiport --sports 20,21,80 -j ACCEPT [0:0] -A INPUT -p tcp -j REJECT --reject-with icmp-port-unreachable [0:0] -A OUTPUT -o lo -j ACCEPT [0:0] -A OUTPUT -p tcp -m multiport -s 10.0.222.8 --dports 20,21,80 -j ACCEPT COMMIT # Completed on Sat May 29 20:53:21 2004 и всё будет работать так, как ты пытаешся сделать. Т.е. для хоста 10.0.222.8 будет разрешен tcp-трафик протоколов HTTP и FTP (в том числе и passive FTP), а всё остальное - запрещено. > Я еще не закончил правила писать, просто несколько раз уже > переписывал все. При таких правилах реально работает только > браузер и ICQ :)) Хотя должен, насколько я понимаю, еще и FTP. > Пробовал поставить правило -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT > вторым в цепочке INPUT до блокирования соединений со всех портов > кроме 20,21,80. Тогда работает вообще все (в том числе и фтп). Работаетвсё потому, что у тебя OUTPUT-правило разрешает всё для адреса 10.0.222.8. Разреши отправку пакетов только на нужные сервисы и будет то, что ты пытаешся получить. > Как будто запрета tcp соединений нет вообще. Если я правильно > понимаю, все дело в очередности прохождения этих правил? То есть > у меня пакет, который приходит с 21 порта принимается и уже не > проводится проверка его состояния? Так что ли? Проверка производится по цепочке сверху вниз, до первого совпадения. > В общем у меня пока получается либо разрешить нужные мне протоколы > (но тогда фтп не работает), либо сделать так, чтобы фтп работало > (но тогда не получается запретить соединения по ненужным мне протоколам). > Как-нибудь можно добиться и того, и другого? :)) > Может с цепочкой INPUT похимичить? :)) Химичь с цепочкой OUTPUT. Хотя, если тебе не нужен passive FTP, можно выбросить '-m state' и рулить только INPUT-цепочкой, но это - не очень хорошая идея ... ;) -- WBR, Dmitry Lebkov PS. Настрой в своем почтовом клиенте line wrapping на 73 символа - надоело переформатировать очень длинные квоты при ответе ... ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-05-30 1:40 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-05-29 17:16 ` [Comm] Re: Помогите разобраться с iptables Juveman 2004-05-30 1:40 ` Dmitry Lebkov
ALT Linux Community general discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 community community/ http://lore.altlinux.org/community \ mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com public-inbox-index community Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.community AGPL code for this site: git clone https://public-inbox.org/public-inbox.git