LinuxForum.Fans
Тема

Помощь в настройке маршрутов

Автор: unlimited 101 сообщений 19459 просмотров
#225169

Вместо прописывания пары правил в фаервол - все равно прописали в фаервол, только через костыль в "ручном" режиме. Не ищут люди легких путей... :D

#225171
UTiM написал:
Вместо прописывания пары правил в фаервол - все равно прописали в фаервол, только через костыль в "ручном" режиме. Не ищут люди легких путей... :D

Это самый правильный путь!!! А вот ваши всякие гуи как раз и костыль.

#225173

Все на ассемблер!
Вообще-то это не гуй, а скрипт, генерирующий правила iptables из правил, заданных в более "человеческом" виде. Особенно это важно, когда число правил переваливает за пару десятков... Если разработчики Suse предусмотрели данный механизм - то наверное думали, что делали. По сути не надо пытаться SuSEFirewall заставлять генерить нужные правила, а просто использовать для настройки сети. Как это делается - вот подробный пример без лишнего флуда: http://unixforum.org/index.php?showtopic=111464 - почитайте, если не лень.

#225176

UTiM, бесспорно, может Suse Firewall и удобная штука, может разработчики. и продумали все от и до... Оно вам там в Suse видней.
Но мне надстройки над надстройками всегда казались лишним, что Shorewall, что Arno's Iptables Firewall или UFW - Uncomplicated Firewall.
Сравнение с ассемблером тут слишком избыточно. Правила iptables пишутся довольно понятно, а вот вникать в обертки оберток, не зная как на самом деле работает iptables вызывает большую путанницо. Хотя это только мое мнение.

#225178
newzenon написал:
Правила iptables пишутся довольно понятно, а вот вникать в обертки оберток, не зная как на самом деле работает iptables вызывает большую путанницо.

+1.

UTiM написал:
Все на ассемблер!

асм тут не причём. iptables тоже обёртка на самом деле.после знакомства с мануалом там нет никаких сложностей. Да и манул есть на русском. http://www.opennet.ru/docs/RUS/iptables/ Читайте.

#225183

Знать основы безусловно надо и полезно. Но пользоваться - тем, чем удобнее в конкретном случае. Сознательное усложнение задачи допустимо только в учебных целях или если по другому ее решить невозможно. В повседневной практике (если это не шлюз, где всем все можно)- и правил iptables слишком много - их редактирование превращается в тихий кошмар. Или просто надо сделать быстро. Вот тут и нужны надстройки.

#225203

Ну и где уважаемые модераторы с плашкой [ФЛЕЙМ] в этом холиваре?

По существу- не нравиться SuSEFirewall - не используй. А лучше выбери другой дистрибутив. В сообществе SUSE давно уже сложилось свое мнение, что должно быть в дистрибутиве, а что нет.

#225256
UTiM написал:
Все на ассемблер!
Вообще-то это не гуй, а скрипт, генерирующий правила iptables из правил, заданных в более "человеческом" виде. Особенно это важно, когда число правил переваливает за пару десятков... Если разработчики Suse предусмотрели данный механизм - то наверное думали, что делали. По сути не надо пытаться SuSEFirewall заставлять генерить нужные правила, а просто использовать для настройки сети. Как это делается - вот подробный пример без лишнего флуда: http://unixforum.org/index.php?showtopic=111464 - почитайте, если не лень.

За пару десятков? :D :D :D Вам показать мои скрипты?
И я в них как рыба в воде.

#225263
Kettler написал:
Вам показать мои скрипты?

да. пригодятся.

#225265

Уважаемые знатоки iptablesa - по теме:
Вы разрешили хождение пакетов из eth0 в eth1 и наоборот. И этого достаточно.

text

iptables -I FORWARD 1 -i eth0 -o eth1 -j ACCEPT
iptables -I FORWARD 1 -i eth1 -o eth0 -j ACCEPT

А вот накой вы включили на обоих интерфейсах маскарадинг?

text

iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --table nat --append POSTROUTING --out-interface eth1 -j MASQUERADE

Работать оно так будет конечно. Шлюз будет прятать аипишники из обох сетей - но зачем и от кого? (Адреса сетей не совпадают) В лучшем случае вы в последствии получите лишний и малопонятный геморой с хождением некоторых типов трафика.

Типа рулить умеем, но зачем и куда ехать не понимаем?

#225266
UTiM написал:
А вот накой вы включили на обоих интерфейсах маскарадинг?

не знаю. Вообще не понимаю, зачем тут DNAT, если уж NAT, то SNAT. Тогда узлы в первой сети, во второй могут иметь IP из второй сети, т.е. быть внутренними. Хотя зачем и кому это надо - я не знаю.

#225297
drBatty написал:
[quote=UTiM]А вот накой вы включили на обоих интерфейсах маскарадинг?

не знаю. Вообще не понимаю, зачем тут DNAT, если уж NAT, то SNAT. Тогда узлы в первой сети, во второй могут иметь IP из второй сети, т.е. быть внутренними. Хотя зачем и кому это надо - я не знаю.[/quote]
Поэтому я написал что DNAT для теста а после SNAT.

#225299
UTiM написал:

А вот накой вы включили на обоих интерфейсах маскарадинг?

Я не телепат чтоб знать какую подсеть автор темы хотел расшарить.
Поэтому завёл и обе.

#225544
Kettler написал:

После.

[console]nano /etc/sysconfig/scripts/SuSEfirewall2-custom[/console]

И туда

[console]iptables -I FORWARD 1 -i eth0 -o eth1 -j ACCEPT
iptables -I FORWARD 1 -i eth1 -o eth0 -j ACCEPT
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --table nat --append POSTROUTING --out-interface eth1 -j MASQUERADE[/console]

куда конкретно в нано вставлять эти строки?

#
# Authors: Marc Heuse,
# Volker Kuhlmann <kuhlmav@elec.canterbury.ac.nz>
#
# /etc/sysconfig/scripts/SuSEfirewall2-custom
#
# ------------------------------------------------------------------------
#
# This is file is for SuSEfirewall2 and is an example for using
# the hooks which are supplied to load customized ipchains rules.
#
# THERE IS NO HELP FOR USING HOOKS EXCEPT THIS FILE ! SO READ CAREFULLY !
# IT IS USEFUL TO CROSS-READ /sbin/SuSEfirewall2 TO SEE HOW HOOKS WORK !
#
# ------------------------------------------------------------------------

fw_custom_after_chain_creation() {
# these rules will be loaded after the various input_* and forward_* chains
# are created.
# You can use this hook to allow/deny certain IP protocols or TCP/UDP
# ports before the SuSEfirewall2 generated rules are hit.

#example: always filter backorifice/netbus trojan connect requests and log them.
#for target in LOG DROP; do
# for chain in input_ext input_dmz input_int forward_int forward_ext forward_dmz; do
# iptables -A $chain -j $target -p tcp --dport 31337
# iptables -A $chain -j $target -p udp --dport 31337
# iptables -A $chain -j $target -p tcp --dport 12345:12346
# iptables -A $chain -j $target -p udp --dport 12345:12346
# done
#done

true
}

fw_custom_before_port_handling() {
# these rules will be loaded after the anti-spoofing and icmp handling
# and after the input has been redirected to the input_XXX and
# forward_XXX chains and some basic chain-specific anti-circumvention
# rules have been set,
# but before any IP protocol or TCP/UDP port allow/protection rules
# will be set.
# You can use this hook to allow/deny certain IP protocols or TCP/UDP
# ports before the SuSEfirewall2 generated rules are hit.

true
}

fw_custom_before_masq() { # could also be named "after_port_handling()"
# these rules will be loaded after the IP protocol and TCP/UDP port
# handling, but before any IP forwarding (routing), masquerading
# will be done.
# NOTE: reverse masquerading is before directly after
# fw_custom_before_port_handling !!!!
# You can use this hook to ... hmmm ... I'm sure you'll find a use for
# this ...

true
}

fw_custom_before_denyall() { # could also be named "after_forwardmasq()"
# these are the rules to be loaded after IP forwarding and masquerading
# but before the logging and deny all section is set by SuSEfirewall2.
# You can use this hook to prevent the logging of annoying packets.

#example: prevent logging of talk requests from anywhere
fw_custom_before_port_handling() {
# these rules will be loaded after the anti-spoofing and icmp handling
# and after the input has been redirected to the input_XXX and
# forward_XXX chains and some basic chain-specific anti-circumvention
# rules have been set,
# but before any IP protocol or TCP/UDP port allow/protection rules
# will be set.
# You can use this hook to allow/deny certain IP protocols or TCP/UDP
# ports before the SuSEfirewall2 generated rules are hit.

true
}

fw_custom_before_masq() { # could also be named "after_port_handling()"
# these rules will be loaded after the IP protocol and TCP/UDP port
# handling, but before any IP forwarding (routing), masquerading
# will be done.
# NOTE: reverse masquerading is before directly after
# fw_custom_before_port_handling !!!!
# You can use this hook to ... hmmm ... I'm sure you'll find a use for
# this ...

true
}

fw_custom_before_denyall() { # could also be named "after_forwardmasq()"
# these are the rules to be loaded after IP forwarding and masquerading
# but before the logging and deny all section is set by SuSEfirewall2.
# You can use this hook to prevent the logging of annoying packets.

#example: prevent logging of talk requests from anywhere
#for chain in input_ext input_dmz input_int forward_int forward_ext forward_dmz; do
# iptables -A $chain -j DROP -p udp --dport 517:518
#done

true
}

благодарю

#225632

Функция fw_custom_after_chain_creation() до строчки true.

#225638

скопипастил..пинга между сетями нет..((((

#
# Authors: Marc Heuse,
# Volker Kuhlmann <kuhlmav@elec.canterbury.ac.nz>
#
# /etc/sysconfig/scripts/SuSEfirewall2-custom
#
# ------------------------------------------------------------------------
#
# This is file is for SuSEfirewall2 and is an example for using
# the hooks which are supplied to load customized ipchains rules.
#
# THERE IS NO HELP FOR USING HOOKS EXCEPT THIS FILE ! SO READ CAREFULLY !
# IT IS USEFUL TO CROSS-READ /sbin/SuSEfirewall2 TO SEE HOW HOOKS WORK !
#
# ------------------------------------------------------------------------

fw_custom_after_chain_creation() {
iptables -I FORWARD 1 -i eth0 -o eth1 -j ACCEPT
iptables -I FORWARD 1 -i eth1 -o eth0 -j ACCEPT
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --table nat --append POSTROUTING --out-interface eth1 -j MASQUERADE
# these rules will be loaded after the various input_* and forward_* chains
# are created.
# You can use this hook to allow/deny certain IP protocols or TCP/UDP
# ports before the SuSEfirewall2 generated rules are hit.

#example: always filter backorifice/netbus trojan connect requests and log them.
#for target in LOG DROP; do
# for chain in input_ext input_dmz input_int forward_int forward_ext forward_dmz; do
# iptables -A $chain -j $target -p tcp --dport 31337
# iptables -A $chain -j $target -p udp --dport 31337
# iptables -A $chain -j $target -p tcp --dport 12345:12346
# iptables -A $chain -j $target -p udp --dport 12345:12346
# done
#done

true
}

fw_custom_before_port_handling() {
# these rules will be loaded after the anti-spoofing and icmp handling
# and after the input has been redirected to the input_XXX and
# forward_XXX chains and some basic chain-specific anti-circumvention
# rules have been set,
# but before any IP protocol or TCP/UDP port allow/protection rules
# will be set.
# You can use this hook to allow/deny certain IP protocols or TCP/UDP
# ports before the SuSEfirewall2 generated rules are hit.

true
}

fw_custom_before_masq() { # could also be named "after_port_handling()"
# these rules will be loaded after the IP protocol and TCP/UDP port
# handling, but before any IP forwarding (routing), masquerading
# will be done.
# NOTE: reverse masquerading is before directly after
# fw_custom_before_port_handling !!!!
# You can use this hook to ... hmmm ... I'm sure you'll find a use for
# this ...

true
}
#225641

правильно вставил? закомментированные строки удалать не надо?

#225653

Нет не надо.
Покажите выхлоп:
/sbin/SuSEfirewall2 stop
/sbin/SuSEfirewall2 start

#225657

linux-66f2:/home/lavr # nano /etc/sysconfig/scripts/SuSEfirewall2-custom
linux-66f2:/home/lavr # /sbin/SuSEfirewall2 stop
SuSEfirewall2: batch committing...
SuSEfirewall2: Firewall rules unloaded.
linux-66f2:/home/lavr # /sbin/SuSEfirewall2 start
SuSEfirewall2: Setting up rules from /etc/sysconfig/SuSEfirewall2 ...
SuSEfirewall2: batch committing...
SuSEfirewall2: Firewall rules successfully set
linux-66f2:/home/lavr #

#225659

У вас не загружается правила. Выполните:
sudo /sbin/yast2 sysconfig set FW_CUSTOMRULES="/etc/sysconfig/scripts/SuSEfirewall2-custom"
sudo /sbin/SuSEfirewall2 stop
sudo /sbin/SuSEfirewall2 start

Войдите или зарегистрируйтесь, чтобы ответить.