From: Michael Shigorin <mike@osdn.org.ua>
To: community@altlinux.ru
Cc: bloodmary@altlinux.ru
Subject: [Comm] IA: iptables bolvanka, fixed version (was: iptables vs ipchains)
Date: Wed, 22 Dec 2004 17:00:31 +0200
Message-ID: <20041222150031.GP9534@osdn.org.ua> (raw)
In-Reply-To: <41C98113.8020607@iop.kiev.ua>
[-- Attachment #1.1: Type: text/plain, Size: 1619 bytes --]
On Wed, Dec 22, 2004 at 04:13:39PM +0200, Andriy Dobrovol's'kii wrote:
> >PS: моя дежурная болванка в аттаче, если кто-либо в благодарность
> >проверит, доточит, проверит и предложит в FAQ -- welcome.
> Миш, какя ж это болванка, если всюду пробиты конкретные адреса
Только не всюду, там есть _REAL_IP :)
Подразумевается: мир через eth0 (_REAL_IP) доступен в локальной
сети 10.0.1.0/24 через интерфейс eth1 (10.0.1.1).
При этом снаружи открыт специфицированный список портов и RELATED
packets, организованы цепочки для подсчёта трафика (eth1-in и
eth1-out), ....упс.
Перечитал скрипт, почесал в затылке, что на originating host уже
давно не добраться (земля той конторе пухом), порасставлял eth0 и
eth1 _адекватно_ адресам и заодно добавил комментариев.
Предыдущую версию считать не болванкой, а провокацией, болванкой
же считать приложенную :-)
> и интерфейсы. И никаких коментариев.
Вот потому так и охарактеризовал, и bloodmary@ на днях отказал
повесить в FAQ. (а вот теперь ближе к терпимому)
> Откоментированный скрипт её генерации с разумно
> абстрагированными переменными был бы болванкой...
Не, это был бы ещё один скрипт генерации, который мне нафиг не
упал, поскольку эта болванка _для меня_ превращается в рабочую за
пару минут в редакторе.
> P.S. Могу прислать свою попытку сделать такой, но, она застряла
> на "дверном" варианте и врядли представляет интерес. Уж больно
> жизнь разнообразна...
Впору dotfiles.altlinux.ru делать по мотивам dotfiles.com :-)
--
---- WBR, Michael Shigorin <mike@altlinux.ru>
------ Linux.Kiev http://www.linux.kiev.ua/
[-- Attachment #1.2: iptables --]
[-- Type: text/plain, Size: 2375 bytes --]
# setup:
# world<->eth0[_REAL_IP]:::eth1[10.0.0.254]<->LAN
# _REAL_IP:_EXT_PORT is port-forwarded to _INT_HOST:_INT_PORT
# everything from inside gets masqueraded,
# with a few host-specific exceptions;
# everything from outside gets dropped unless
# targets explicitly allowed port
# or is a response to our request
# eth0-in/eth0-out count [paid] external traffic
# Generated by iptables-save v1.2.6a on Thu Nov 21 21:15:39 2002
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -d _REAL_IP -i eth0 -p tcp -m tcp --dport _EXT_PORT -j DNAT --to-destination _INT_HOST:_INT_PORT
-A POSTROUTING -s 10.0.0.0/24 -d ! 10.0.0.0/24 -j SNAT --to-source _REAL_IP
COMMIT
# Completed on Thu Nov 21 21:15:39 2002
# Generated by iptables-save v1.2.6a on Thu Nov 21 21:15:39 2002
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed on Thu Nov 21 21:15:39 2002
# Generated by iptables-save v1.2.6a on Thu Nov 21 21:15:39 2002
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:eth0-in - [0:0]
:eth0-out - [0:0]
:tcprules - [0:0]
-A INPUT -i eth0 -j eth0-in
-A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
-A INPUT -s 10.0.0.0/24 -d 10.0.0.254 -i eth1 -j ACCEPT
-A INPUT -s 10.0.0.0/24 -d _REAL_IP -i eth1 -j ACCEPT
-A INPUT -d _REAL_IP -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -d _REAL_IP -i eth0 -p tcp -m tcp --dport 25 -j ACCEPT
-A INPUT -d _REAL_IP -i eth0 -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -d _REAL_IP -i eth0 -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -d _REAL_IP -i eth0 -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -d _REAL_IP -i eth0 -p tcp -m tcp --dport 110 -j ACCEPT
-A INPUT -d _REAL_IP -i eth0 -p tcp -m tcp --dport 113 -j REJECT --reject-with tcp-reset
-A INPUT -j tcprules
# block :25 to world (only through 10.0.0.1:25)
-A FORWARD -s 10.0.0.0/24 -p tcp -m tcp --dport 25 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -j tcprules
-A OUTPUT -o eth0 -j eth0-out
-A eth0-in -j RETURN
-A eth0-out -j RETURN
-A tcprules -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A tcprules -i ! eth0 -m state --state NEW -j ACCEPT
-A tcprules -i eth0 -m state --state INVALID,NEW -j DROP
-A tcprules -i eth0 -j REJECT --reject-with icmp-host-unreachable
COMMIT
# Completed on Thu Nov 21 21:15:39 2002
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2004-12-22 15:00 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-16 16:15 [Comm] Как настроить шлюз в инет? Denis Kirienko
2004-12-16 16:29 ` Jury Levykin
2004-12-16 16:43 ` Denis Kirienko
2004-12-16 17:03 ` Denis Kirienko
2004-12-16 20:34 ` Jury Levykin
2004-12-16 20:43 ` Denis Kirienko
2004-12-16 16:30 ` Alexey S. Kuznetsov
2004-12-16 16:35 ` Jury Levykin
2004-12-16 20:08 ` Re[2]: " Alexey S. Kuznetsov
2004-12-16 19:28 ` Sergey Vlasov
2004-12-17 5:59 ` Mike Lykov
2004-12-17 6:15 ` Шишков Евгений
2004-12-17 11:20 ` Re[2]: " Alexey S. Kuznetsov
2004-12-20 15:03 ` Andrey Rahmatullin
2004-12-20 16:28 ` [Comm] " Michael Shigorin
2004-12-20 22:33 ` [Comm] " Alexey S. Kuznetsov
2004-12-20 20:50 ` Denis Kirienko
2004-12-20 23:19 ` Alexey S. Kuznetsov
2004-12-22 13:49 ` [Comm] " Michael Shigorin
2004-12-21 9:55 ` [Comm] " Oleg Shulga
2004-12-21 5:01 ` Mike Lykov
2004-12-22 13:49 ` [Comm] iptables vs ipchains (was: Как настроить шлюз в инет?) Michael Shigorin
2004-12-22 14:13 ` [Comm] iptables vs ipchains Andriy Dobrovol's'kii
2004-12-22 14:25 ` Alexey Morsov
2004-12-22 14:47 ` Serge Polkovnikov
2004-12-22 14:53 ` Igor Solovyov
2004-12-22 14:59 ` Serge Polkovnikov
2004-12-22 15:00 ` Alexey I. Froloff
2004-12-22 15:43 ` [Comm] iptables vs ipchains [JT] Denis Kirienko
2004-12-22 15:00 ` Michael Shigorin [this message]
2004-12-22 16:22 ` [Comm] IA: iptables bolvanka, fixed version (was: iptables vs ipchains) Andrey Rahmatullin
2004-12-22 17:05 ` [Comm] dotfiles.com Michael Shigorin
2004-12-22 17:51 ` [Comm] IA: iptables bolvanka, fixed version (was: iptables vs ipchains) Maxim Tyurin
2004-12-22 15:30 ` [Comm] iptables vs ipchains (was: Как настроить шлюз в инет?) Alexey S. Kuznetsov
2004-12-22 15:39 ` Denis Kirienko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041222150031.GP9534@osdn.org.ua \
--to=mike@osdn.org.ua \
--cc=bloodmary@altlinux.ru \
--cc=community@altlinux.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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