* [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси @ 2008-05-06 7:38 Денис Ягофаров 0 siblings, 1 reply; 16+ messages in thread From: Денис Ягофаров @ 2008-05-06 7:38 UTC (permalink / raw) To: sysadmins [-- Attachment #1: Type: text/plain, Size: 497 bytes --] Доброго времени суток! Пробую заставить iptables перенаправлять трафик http-запросов на сервер с прозрачным squid (http_port 3128 transparent). Использую правила на роутере: # iptables -t nat -A PREROUTING -i 192.168.0.0/16 -p tcp --dport 80 -j DNAT --to 10.3.0.5:3128 # iptables -t nat -A PREROUTING -i 192.168.0.0/16 -p tcp --dport 21 -j DNAT --to 10.3.0.5:3128 Что я забыл? [-- Attachment #2: denyago.vcf --] [-- Type: text/x-vcard, Size: 279 bytes --] begin:vcard fn:Denis Timurovich Yagofarov n:Yagofarov;Denis Timurovich org:ITGIS NASU adr:room 615;;Chokolovski sqr., 13;Kiev;;03151;Ukraine email;internet:denyago@rambler.ru title:system administrator tel;work:80442480755 x-mozilla-html:FALSE version:2.1 end:vcard ^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <685314b70805060040u2682a682qed61f8d6927bfd8@mail.gmail.com>]
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси @ 2008-05-06 8:01 ` Денис Ягофаров 2008-05-06 8:07 ` Владимир 2008-05-06 8:27 ` Motsyo Gennadi aka Drool 0 siblings, 2 replies; 16+ messages in thread From: Денис Ягофаров @ 2008-05-06 8:01 UTC (permalink / raw) To: ALT Linux sysadmin discuss [-- Attachment #1: Type: text/plain, Size: 1501 bytes --] Всеволод Мартыненко пишет: > А почему не SNAT? Это же запросы из внутренней сети Вы перенаправляете? > > 6 мая 2008 г. 13:38 пользователь Денис Ягофаров <denyago@rambler.ru > <mailto:denyago@rambler.ru>> написал: > > Использую > правила на роутере: > # iptables -t nat -A PREROUTING -i 192.168.0.0/16 > <http://192.168.0.0/16> -p tcp --dport 80 -j DNAT --to > 10.3.0.5:3128 <http://10.3.0.5:3128> > # iptables -t nat -A PREROUTING -i 192.168.0.0/16 > <http://192.168.0.0/16> -p tcp --dport 21 -j DNAT --to > 10.3.0.5:3128 <http://10.3.0.5:3128> > > Что я забыл? > хм... # iptables -t nat -A PREROUTING -i 192.168.0.0/16 -p tcp --dport 21 -j SNAT --to 10.3.0.5:3128 iptables: Invalid argument Согласно http://ru.wikipedia.org/wiki/Netfilter : *nat* — просматривает только пакеты, создающие новое соединение (согласно системе определения состояний). Поддерживает действия /DNAT/, /SNAT/, /MASQUERADE/, /REDIRECT/. Содержит цепочки /PREROUTING/, /OUTPUT/, и /POSTROUTING У меня роутер живёт в OVZ контейнере, может ему не хватает модулей? Хотя в конфиге ему указано: IPTABLES="iptable_filter iptable_nat " / [-- Attachment #2: denyago.vcf --] [-- Type: text/x-vcard, Size: 279 bytes --] begin:vcard fn:Denis Timurovich Yagofarov n:Yagofarov;Denis Timurovich org:ITGIS NASU adr:room 615;;Chokolovski sqr., 13;Kiev;;03151;Ukraine email;internet:denyago@rambler.ru title:system administrator tel;work:80442480755 x-mozilla-html:FALSE version:2.1 end:vcard ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси 2008-05-06 8:01 ` Денис Ягофаров @ 2008-05-06 8:07 ` Владимир 2008-05-06 8:33 ` Денис Ягофаров 2008-05-06 8:27 ` Motsyo Gennadi aka Drool 1 sibling, 1 reply; 16+ messages in thread From: Владимир @ 2008-05-06 8:07 UTC (permalink / raw) To: ALT Linux sysadmin discuss Денис Ягофаров пишет: > Всеволод Мартыненко пишет: >> А почему не SNAT? Это же запросы из внутренней сети Вы перенаправляете? >> >> 6 мая 2008 г. 13:38 пользователь Денис Ягофаров <denyago@rambler.ru >> <mailto:denyago@rambler.ru>> написал: >> >> Использую >> правила на роутере: >> # iptables -t nat -A PREROUTING -i 192.168.0.0/16 >> <http://192.168.0.0/16> -p tcp --dport 80 -j DNAT --to >> 10.3.0.5:3128 <http://10.3.0.5:3128> >> # iptables -t nat -A PREROUTING -i 192.168.0.0/16 >> <http://192.168.0.0/16> -p tcp --dport 21 -j DNAT --to >> 10.3.0.5:3128 <http://10.3.0.5:3128> >> >> Что я забыл? >> > хм... > # iptables -t nat -A PREROUTING -i 192.168.0.0/16 -p tcp --dport 21 -j > SNAT --to 10.3.0.5:3128 > iptables: Invalid argument > Все правильно, если SNAT, то цепочка POSTROUTING > Согласно http://ru.wikipedia.org/wiki/Netfilter : > *nat* — просматривает только пакеты, создающие новое соединение > (согласно системе определения состояний). Поддерживает действия > /DNAT/, /SNAT/, /MASQUERADE/, /REDIRECT/. Содержит цепочки > /PREROUTING/, /OUTPUT/, и /POSTROUTING > > У меня роутер живёт в OVZ контейнере, может ему не хватает модулей? > Хотя в конфиге ему указано: > IPTABLES="iptable_filter iptable_nat " > / > _______________________________________________ > Sysadmins mailing list > Sysadmins@lists.altlinux.org > https://lists.altlinux.org/mailman/listinfo/sysadmins > -- Vladimir Kholmanov fmfm@mmascience.ru fmfm@mma.ru ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси 2008-05-06 8:07 ` Владимир @ 2008-05-06 8:33 ` Денис Ягофаров 0 siblings, 0 replies; 16+ messages in thread From: Денис Ягофаров @ 2008-05-06 8:33 UTC (permalink / raw) To: ALT Linux sysadmin discuss [-- Attachment #1: Type: text/plain, Size: 2138 bytes --] Владимир пишет: > Денис Ягофаров пишет: >> хм... >> # iptables -t nat -A PREROUTING -i 192.168.0.0/16 -p tcp --dport 21 >> -j SNAT --to 10.3.0.5:3128 >> iptables: Invalid argument >> > > Все правильно, если SNAT, то цепочка POSTROUTING Прописали.... #iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 80 -j SNAT --to 10.3.0.5:3128 Пробуем полазать по гуглу. В теории 10.3.0.5 должен про него спрашивать _не_ мой хост: # tcpdump -i veth1 src host 192.168.1.1 or src host 10.3.0.2 or dst host 192.168.1.1 or dst host 10.3.0.2 А вот на исходящем интерфейсе роутера: # tcpdump -i eth1 src host 192.168.1.111 and dst port 80 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes 13:32:43.255632 IP 192.168.1.111.4777 > fk-in-f99.google.com.http: S 3757065542:3757065542(0) win 65535 <mss 1460,nop,nop,sackOK> 13:32:43.306224 IP 192.168.1.111.4777 > fk-in-f99.google.com.http: . ack 1970806748 win 65535 13:32:43.306724 IP 192.168.1.111.4777 > fk-in-f99.google.com.http: P 0:750(750) ack 1 win 65535 13:32:43.390926 IP 192.168.1.111.4777 > fk-in-f99.google.com.http: . ack 3094 win 65535 Увы, пакеты в цепочку не попадают :( # iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination # iptables -t nat -L Chain PREROUTING (policy ACCEPT) target prot opt source destination Chain POSTROUTING (policy ACCEPT) target prot opt source destination SNAT tcp -- anywhere anywhere tcp dpt:http to:10.3.0.5:3128 SNAT tcp -- anywhere anywhere tcp dpt:ftp to:10.3.0.5:3128 Chain OUTPUT (policy ACCEPT) target prot opt source destination [-- Attachment #2: denyago.vcf --] [-- Type: text/x-vcard, Size: 279 bytes --] begin:vcard fn:Denis Timurovich Yagofarov n:Yagofarov;Denis Timurovich org:ITGIS NASU adr:room 615;;Chokolovski sqr., 13;Kiev;;03151;Ukraine email;internet:denyago@rambler.ru title:system administrator tel;work:80442480755 x-mozilla-html:FALSE version:2.1 end:vcard ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси 2008-05-06 8:01 ` Денис Ягофаров 2008-05-06 8:07 ` Владимир @ 2008-05-06 8:27 ` Motsyo Gennadi aka Drool 2008-05-06 8:43 ` Денис Ягофаров 1 sibling, 1 reply; 16+ messages in thread From: Motsyo Gennadi aka Drool @ 2008-05-06 8:27 UTC (permalink / raw) To: ALT Linux sysadmin discuss [-- Attachment #1: Type: text/plain, Size: 193 bytes --] Денис Ягофаров пишет: >> Что я забыл? Я себе для такого соорудил инит-скрипт. Прилагаю для рассмотрения. [-- Attachment #2: nat --] [-- Type: text/plain, Size: 1037 bytes --] #!/bin/sh # chkconfig: 2345 13 89 # description: NAT . /etc/init.d/functions case "$1" in start) $0 stop echo -n "Starting NAT: " iptables -I PREROUTING -t nat -s 192.168.2.0/24 -p tcp --dport 80 -j DNAT --to 192.168.1.14:3128 \ && iptables -I PREROUTING -t nat -s 192.168.1.0/24 -p tcp --dport 80 -j DNAT --to 192.168.1.14:3128 \ && echo 1 > /proc/sys/net/ipv4/ip_forward \ && iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o eth0 -j MASQUERADE \ && success echo ;; stop) echo -n "Stopping NAT: " echo 0 > /proc/sys/net/ipv4/ip_forward \ && iptables -t filter -F \ && iptables -t filter -X \ && iptables -t nat -F \ && iptables -t nat -X \ && success echo ;; status) echo -n "Status NAT: " echo && iptables -L -t nat echo ;; restart) $0 stop $0 start ;; *) echo "Usage: nat {start|stop|status|restart}" exit 1 ;; esac exit $RETVAL ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси 2008-05-06 8:27 ` Motsyo Gennadi aka Drool @ 2008-05-06 8:43 ` Денис Ягофаров 2008-05-06 8:46 ` Motsyo Gennadi aka Drool 2008-05-06 9:36 ` Timur Batyrshin 0 siblings, 2 replies; 16+ messages in thread From: Денис Ягофаров @ 2008-05-06 8:43 UTC (permalink / raw) To: ALT Linux sysadmin discuss [-- Attachment #1: Type: text/plain, Size: 1267 bytes --] Motsyo Gennadi aka Drool пишет: > Я себе для такого соорудил инит-скрипт. Прилагаю для рассмотрения. > ... iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o eth0 -j MASQUERADE ... # iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -o eth0 -j MASQUERADE iptables: No chain/target/match by that name хм... ему для OVZ дополнительные модули нужны? Всё, что есть на HN: $ lsmod | grep ip ip_conntrack_netlink 36736 0 ipt_REDIRECT 10752 0 xt_multiport 12160 0 iptable_nat 19332 16 ip_nat 30352 4 ip_conntrack_netlink,ipt_REDIRECT,vzrst,iptable_nat ip_conntrack 80788 12 ip_conntrack_netlink,vzrst,vzcpt,iptable_nat,ip_nat nfnetlink 16456 3 ip_conntrack_netlink,ip_nat,ip_conntrack ipt_ttl 10624 0 ipt_TCPMSS 13184 0 iptable_mangle 13696 4 iptable_filter 13568 7 ipt_tos 10368 0 ipt_REJECT 14336 0 ip_tables 32872 3 iptable_nat,iptable_mangle,iptable_filter x_tables 29704 9 ipt_REDIRECT,xt_multiport,xt_tcpudp,iptable_nat,ipt_ttl,ipt_TCPMSS,ipt_tos,ipt_REJECT,ip_tables [-- Attachment #2: denyago.vcf --] [-- Type: text/x-vcard, Size: 279 bytes --] begin:vcard fn:Denis Timurovich Yagofarov n:Yagofarov;Denis Timurovich org:ITGIS NASU adr:room 615;;Chokolovski sqr., 13;Kiev;;03151;Ukraine email;internet:denyago@rambler.ru title:system administrator tel;work:80442480755 x-mozilla-html:FALSE version:2.1 end:vcard ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси 2008-05-06 8:43 ` Денис Ягофаров @ 2008-05-06 8:46 ` Motsyo Gennadi aka Drool 2008-05-06 8:55 ` Денис Ягофаров 2008-05-06 9:36 ` Timur Batyrshin 1 sibling, 1 reply; 16+ messages in thread From: Motsyo Gennadi aka Drool @ 2008-05-06 8:46 UTC (permalink / raw) To: ALT Linux sysadmin discuss Денис Ягофаров пишет: > Motsyo Gennadi aka Drool пишет: >> Я себе для такого соорудил инит-скрипт. Прилагаю для рассмотрения. >> ... iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o eth0 -j >> MASQUERADE ... > # iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -o eth0 -j MASQUERADE > iptables: No chain/target/match by that name А у Вас в контейнере eth0 ? ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси 2008-05-06 8:46 ` Motsyo Gennadi aka Drool @ 2008-05-06 8:55 ` Денис Ягофаров 0 siblings, 0 replies; 16+ messages in thread From: Денис Ягофаров @ 2008-05-06 8:55 UTC (permalink / raw) To: ALT Linux sysadmin discuss [-- Attachment #1: Type: text/plain, Size: 448 bytes --] Motsyo Gennadi aka Drool пишет: > Денис Ягофаров пишет: >> Motsyo Gennadi aka Drool пишет: >>> Я себе для такого соорудил инит-скрипт. Прилагаю для рассмотрения. >>> ... iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o eth0 -j >>> MASQUERADE ... >> # iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -o eth0 -j MASQUERADE >> iptables: No chain/target/match by that name > > А у Вас в контейнере eth0 ? да. проброшен: NETDEV="eth1 eth0" [-- Attachment #2: denyago.vcf --] [-- Type: text/x-vcard, Size: 267 bytes --] begin:vcard fn:Denis Timurovich Yagofarov n:Yagofarov;Denis Timurovich org:ITGIS NASU adr:room 615;;Chokolovski sqr., 13;Kiev;;03151;Ukraine email;internet:denyago@rambler.ru title:system administrator tel;work:80442480755 x-mozilla-html:FALSE version:2.1 end:vcard ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси 2008-05-06 8:43 ` Денис Ягофаров 2008-05-06 8:46 ` Motsyo Gennadi aka Drool @ 2008-05-06 9:36 ` Timur Batyrshin 2008-05-06 9:50 ` Денис Ягофаров 1 sibling, 1 reply; 16+ messages in thread From: Timur Batyrshin @ 2008-05-06 9:36 UTC (permalink / raw) To: sysadmins On Tue, 06 May 2008 11:43:03 +0300 Денис Ягофаров wrote: > > Я себе для такого соорудил инит-скрипт. Прилагаю для > > рассмотрения. ... iptables -t nat -A POSTROUTING -s 192.168.2.0/24 > > -o eth0 -j MASQUERADE ... > # iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -o eth0 -j > MASQUERADE iptables: No chain/target/match by that name > > хм... ему для OVZ дополнительные модули нужны? Всё, что есть на HN: Не могу ничего сказать насчет модулей, но если на хосте адрес статический, то судя по тому же iptables tutorial лучше использовать вместо маскарада SNAT. Ну и если кроме 80 и 21 порта ничего не должно проходить, то это правило не нужно, зато нужен запрет на прохождение пакетов, т.к. иначе во внешнюю сеть будут валиться пакеты с внутренними адресами. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси 2008-05-06 9:36 ` Timur Batyrshin @ 2008-05-06 9:50 ` Денис Ягофаров 2008-05-06 10:07 ` Timur Batyrshin 0 siblings, 1 reply; 16+ messages in thread From: Денис Ягофаров @ 2008-05-06 9:50 UTC (permalink / raw) To: ALT Linux sysadmin discuss [-- Attachment #1: Type: text/plain, Size: 1460 bytes --] Timur Batyrshin пишет: > On Tue, 06 May 2008 11:43:03 +0300 > Денис Ягофаров wrote: > > >>> Я себе для такого соорудил инит-скрипт. Прилагаю для >>> рассмотрения. ... iptables -t nat -A POSTROUTING -s 192.168.2.0/24 >>> -o eth0 -j MASQUERADE ... >>> >> # iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -o eth0 -j >> MASQUERADE iptables: No chain/target/match by that name >> >> хм... ему для OVZ дополнительные модули нужны? Всё, что есть на HN: >> > > Не могу ничего сказать насчет модулей, но если на хосте адрес > статический, то судя по тому же iptables tutorial лучше использовать > вместо маскарада SNAT. > Ну и если кроме 80 и 21 порта ничего не должно проходить, то это правило > не нужно, зато нужен запрет на прохождение пакетов, т.к. иначе во > внешнюю сеть будут валиться пакеты с внутренними адресами. > Как всё выглядит сейчас: Клиент (у него указан шлюз) -- (eth0 проброшеный в контейнер) роутер (маршрутизация в Сеть) Как я хочу: Клиент (у него указан шлюз) -- (eth0 проброшеный в контейнер) роутер (переброс 80 и 21 портов) -- прокси -- роутер (маршрутизация в Сеть) ... при этом ssh/pop3/smtp и т.п. спокойно проходят в Сеть ... Как я представляю это "на пальцах": NetFilter определяет, что соединение организовывается во внешнюю сеть на 80-й порт, он перенаправляет всё на прокси, и получая ответы от прокси отсылает их коиенту. При этом, как я понимаю, клиент считает, что ему отвечает запрашиваемый ресурс... [-- Attachment #2: denyago.vcf --] [-- Type: text/x-vcard, Size: 267 bytes --] begin:vcard fn:Denis Timurovich Yagofarov n:Yagofarov;Denis Timurovich org:ITGIS NASU adr:room 615;;Chokolovski sqr., 13;Kiev;;03151;Ukraine email;internet:denyago@rambler.ru title:system administrator tel;work:80442480755 x-mozilla-html:FALSE version:2.1 end:vcard ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси 2008-05-06 9:50 ` Денис Ягофаров @ 2008-05-06 10:07 ` Timur Batyrshin 2008-05-06 10:42 ` Денис Ягофаров 0 siblings, 1 reply; 16+ messages in thread From: Timur Batyrshin @ 2008-05-06 10:07 UTC (permalink / raw) To: sysadmins On Tue, 06 May 2008 12:50:27 +0300 Денис Ягофаров wrote: > > Не могу ничего сказать насчет модулей, но если на хосте адрес > > статический, то судя по тому же iptables tutorial лучше использовать > > вместо маскарада SNAT. > > Ну и если кроме 80 и 21 порта ничего не должно проходить, то это > > правило не нужно, зато нужен запрет на прохождение пакетов, т.к. > > иначе во внешнюю сеть будут валиться пакеты с внутренними адресами. > > > Как всё выглядит сейчас: > Клиент (у него указан шлюз) -- (eth0 проброшеный в контейнер) роутер > (маршрутизация в Сеть) > Как я хочу: > Клиент (у него указан шлюз) -- (eth0 проброшеный в контейнер) роутер > (переброс 80 и 21 портов) -- прокси -- роутер (маршрутизация в Сеть) > ... при этом ssh/pop3/smtp и т.п. спокойно проходят в Сеть ... А, тогда SNAT (или MASQUARADE) на выходе с роутера нужны. Если адрес на нем статический -- SNAT, если динамический (ppp-подключение, например) -- MASQUARADE. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси 2008-05-06 10:07 ` Timur Batyrshin @ 2008-05-06 10:42 ` Денис Ягофаров 2008-05-06 11:20 ` Timur Batyrshin 0 siblings, 1 reply; 16+ messages in thread From: Денис Ягофаров @ 2008-05-06 10:42 UTC (permalink / raw) To: ALT Linux sysadmin discuss [-- Attachment #1: Type: text/plain, Size: 738 bytes --] Timur Batyrshin пишет: > On Tue, 06 May 2008 12:50:27 +0300 > Денис Ягофаров wrote >> Как всё выглядит сейчас: >> Клиент (у него указан шлюз) -- (eth0 проброшеный в контейнер) роутер >> (маршрутизация в Сеть) >> Как я хочу: >> Клиент (у него указан шлюз) -- (eth0 проброшеный в контейнер) роутер >> (переброс 80 и 21 портов) -- прокси -- роутер (маршрутизация в Сеть) >> ... при этом ssh/pop3/smtp и т.п. спокойно проходят в Сеть ... >> > А, тогда SNAT (или MASQUARADE) на выходе с роутера нужны. > Если адрес на нем статический -- SNAT, если динамический > (ppp-подключение, например) -- MASQUARADE. > там всюду статика.... если у кого-нибуть есть желание подсказать правило, было бы классно :) ну а коль нет, так ничего... [-- Attachment #2: denyago.vcf --] [-- Type: text/x-vcard, Size: 267 bytes --] begin:vcard fn:Denis Timurovich Yagofarov n:Yagofarov;Denis Timurovich org:ITGIS NASU adr:room 615;;Chokolovski sqr., 13;Kiev;;03151;Ukraine email;internet:denyago@rambler.ru title:system administrator tel;work:80442480755 x-mozilla-html:FALSE version:2.1 end:vcard ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси 2008-05-06 10:42 ` Денис Ягофаров @ 2008-05-06 11:20 ` Timur Batyrshin 2008-05-06 16:51 ` Vyatcheslav Perevalov 0 siblings, 1 reply; 16+ messages in thread From: Timur Batyrshin @ 2008-05-06 11:20 UTC (permalink / raw) To: sysadmins On Tue, 06 May 2008 13:42:22 +0300 Денис Ягофаров wrote: > >> Как всё выглядит сейчас: > >> Клиент (у него указан шлюз) -- (eth0 проброшеный в контейнер) > >> роутер (маршрутизация в Сеть) > >> Как я хочу: > >> Клиент (у него указан шлюз) -- (eth0 проброшеный в контейнер) > >> роутер (переброс 80 и 21 портов) -- прокси -- роутер > >> (маршрутизация в Сеть) ... при этом ssh/pop3/smtp и т.п. спокойно > >> проходят в Сеть ... > > А, тогда SNAT (или MASQUARADE) на выходе с роутера нужны. > > Если адрес на нем статический -- SNAT, если динамический > > (ppp-подключение, например) -- MASQUARADE. > там всюду статика.... > если у кого-нибуть есть желание подсказать правило, было бы > классно :) ну а коль нет, > так ничего... Что-нибудь подобное, если по аналогии с правилом для MASQUARADE делать: iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -o eth0 -j SNAT \ --to-source 111.222.33.44 Здесь 111.222.33.44 -- внешний адрес роутера. Или даже вместо '-o eth0' поставить '-d ! 192.168.0.0/16' ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси 2008-05-06 11:20 ` Timur Batyrshin @ 2008-05-06 16:51 ` Vyatcheslav Perevalov 2008-05-07 7:43 ` Timur Batyrshin 0 siblings, 1 reply; 16+ messages in thread From: Vyatcheslav Perevalov @ 2008-05-06 16:51 UTC (permalink / raw) To: ALT Linux sysadmin discuss В сообщении от 6 мая 2008 Timur Batyrshin написал(a): > > > ................... -- MASQUARADE. > > > > ......................................................................................... > > Что-нибудь подобное, если по аналогии с правилом для MASQUARADE делать: Я ничего не путаю? разве не MASQU_E_RADE (подчёркнуто мной)? -- Всего хорошего /vip ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси 2008-05-06 16:51 ` Vyatcheslav Perevalov @ 2008-05-07 7:43 ` Timur Batyrshin 2008-05-07 8:19 ` Денис Ягофаров 0 siblings, 1 reply; 16+ messages in thread From: Timur Batyrshin @ 2008-05-07 7:43 UTC (permalink / raw) To: sysadmins On Tue, 6 May 2008 23:51:31 +0700 Vyatcheslav Perevalov wrote: > > > > ................... -- MASQUARADE. > > > > > > > ......................................................................................... > > > > Что-нибудь подобное, если по аналогии с правилом для MASQUARADE > > делать: > > Я ничего не путаю? разве не MASQU_E_RADE (подчёркнуто мной)? > Ага, точно, прощу прощения за невнимательность: MASQUERADE This target is only valid in the nat table, in the POSTROUTING chain. It should only be used with dynami- cally assigned IP (dialup) connections: if you have a static IP address, you should use the SNAT target. Masquerading is equivalent to specifying a mapping to the IP address of the interface the packet is going out, but also has the effect that connections are forgotten when the interface goes down. This is the correct behavior when the next dialup is unlikely to have the same interface address (and hence any estab- lished connections are lost anyway). ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси 2008-05-07 7:43 ` Timur Batyrshin @ 2008-05-07 8:19 ` Денис Ягофаров 0 siblings, 0 replies; 16+ messages in thread From: Денис Ягофаров @ 2008-05-07 8:19 UTC (permalink / raw) To: ALT Linux sysadmin discuss [-- Attachment #1: Type: text/plain, Size: 1641 bytes --] Итак, огромное спасибо всем учасникам. Отдельно motsyo@, за пример правил. Как всё решилось, пока.... 1) # cat /etc/vz/conf/10250.conf | grep ip IPTABLES="iptable_filter iptable_nat ipt_MASQUERADE ip_nat_ftp " 2) # cat /etc/vz/vz.conf | grep ip IPTABLES="ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length iptable_nat ipt_MASQUERADE ip_nat_ftp" 3) # iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -o eth0 -j MASQUARADE # iptables -I PREROUTING -t nat -s 192.168.0.0/16 -p tcp --dport 80 -j DNAT --to 10.3.0.5:3128 # iptables -t nat -L Chain PREROUTING (policy ACCEPT) target prot opt source destination DNAT tcp -- 192.168.0.0/16 anywhere tcp dpt:ftp to:10.3.0.5:3128 DNAT tcp -- 192.168.0.0/16 anywhere tcp dpt:http to:10.3.0.5:3128 Chain POSTROUTING (policy ACCEPT) target prot opt source destination MASQUERADE 0 -- 192.168.0.0/16 anywhere Chain OUTPUT (policy ACCEPT) target prot opt source destination Результат: http, судя по логам, перенаправляется куда надо. Извесные проблемы: 1) # vzctl enter router Warning: Unknown iptable module: ipt_MASQUERADE, skipped Warning: Unknown iptable module: ipt_MASQUERADE, skipped entered into VE 10250 Т.к. я не хочу сейчас ещё раз всё перезапускать, хотелось бы знать, отчего таке сообщение: "Warning: Unknown iptable module: ipt_MASQUERADE, skipped" 2) Почему-то не перенаправляется FTP, хотя правило тоже загружено. Этого не заметно по логам прокси и внешний вид загруженой фтп-страницы не меняется. [-- Attachment #2: denyago.vcf --] [-- Type: text/x-vcard, Size: 267 bytes --] begin:vcard fn:Denis Timurovich Yagofarov n:Yagofarov;Denis Timurovich org:ITGIS NASU adr:room 615;;Chokolovski sqr., 13;Kiev;;03151;Ukraine email;internet:denyago@rambler.ru title:system administrator tel;work:80442480755 x-mozilla-html:FALSE version:2.1 end:vcard ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2008-05-07 8:19 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-05-06 7:38 [Sysadmins] Правила на iptables для заворачивания http-трафика на прокси Денис Ягофаров 2008-05-06 8:01 ` Денис Ягофаров 2008-05-06 8:07 ` Владимир 2008-05-06 8:33 ` Денис Ягофаров 2008-05-06 8:27 ` Motsyo Gennadi aka Drool 2008-05-06 8:43 ` Денис Ягофаров 2008-05-06 8:46 ` Motsyo Gennadi aka Drool 2008-05-06 8:55 ` Денис Ягофаров 2008-05-06 9:36 ` Timur Batyrshin 2008-05-06 9:50 ` Денис Ягофаров 2008-05-06 10:07 ` Timur Batyrshin 2008-05-06 10:42 ` Денис Ягофаров 2008-05-06 11:20 ` Timur Batyrshin 2008-05-06 16:51 ` Vyatcheslav Perevalov 2008-05-07 7:43 ` Timur Batyrshin 2008-05-07 8:19 ` Денис Ягофаров
ALT Linux sysadmins discussion This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/sysadmins/0 sysadmins/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 sysadmins sysadmins/ http://lore.altlinux.org/sysadmins \ sysadmins@lists.altlinux.org sysadmins@lists.altlinux.ru sysadmins@lists.altlinux.com public-inbox-index sysadmins Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.sysadmins AGPL code for this site: git clone https://public-inbox.org/public-inbox.git