Nie jesteś zalogowany.
Jeśli nie posiadasz konta, zarejestruj je już teraz! Pozwoli Ci ono w pełni korzystać z naszego serwisu. Spamerom dziękujemy!

Ogłoszenie

Prosimy o pomoc dla małej Julki — przekaż 1% podatku na Fundacji Dzieciom zdazyć z Pomocą.
Więcej informacji na dug.net.pl/pomagamy/.

#1  2008-05-05 00:32:10

  nox - Użytkownik

nox
Użytkownik
Skąd: Lublin
Zarejestrowany: 2008-03-19
Serwis

Firewall - poprawki i pomoc w pisaniu

Zawartość firewall:

Kod:

#-----Zmienne globalne dla calego pakietu------#

source /etc/firewall/users.conf
source /etc/firewall/rates.conf
source /etc/firewall/interfaces.conf
source /etc/firewall/mac.conf

#..............................................#
#       WLACZENIE FORWARDOWANIA                #
#..............................................#

echo 1 > /proc/sys/net/ipv4/ip_forward

#----------------------------------------------#
#               CZYSZCZENIE REGUL              #
#----------------------------------------------#

iptables -F                                             # czyszczenie wpisow
iptables -X                                             # usuniecie lancucha

iptables -t nat -F                                      # czyszczenie tablicy (-t) NAT
iptables -t nat -X                                      # usuniecie lancucha w tabeli

#----------------------------------------------#
#       USTAWAIENIE POLITYKI DZIALANIA         #
#----------------------------------------------#

iptables -P INPUT DROP                                  # domyslna polityka lancucha
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

#----------------------------------------------#
#               SSH DLA SERWERA                #
#----------------------------------------------#
iptables -N SSH                                         # utworzenie nowego lanvucha

iptables -A INPUT -p tcp --dport 22 -j SSH
iptables -A SSH -s $ip_wan_range -j ACCEPT
iptables -A SSH -s $ip_lan_range -j ACCEPT

iptables -A SSH -m limit --limit 5/s -j LOG             # regula logowania
iptables -A SSH -j DROP


#iptables -A INPUT -i $lop -j ACCEPT                    # dodanie reguly do lancucha(-A), na interfejsie(-i), polityka(-j)
#iptables -A FORWARD -o $lop -j ACCEPT

#iptables -A INPUT -s 0/24 -d $ip_lan -p tcp --dport 22 -j ACCEPT               # wybierani zrodla pakietu(-s), maska(-0/0),
#iptables -A OUTPUT -s 0/24 -d $ip_lan -p tcp --dport 22 -j ACCEPT              # adres pakietu(-d), protokol(-p)
#iptables -A INPUT -s 0/24 -d $ip_lan -p udp --dport 22 -j ACCEPT               # okreslenie portu docelowego(--dport)
#iptables -A OUTPUT -s 0/24 -d $ip_lan -p tcp --dport 22 -j ACCEPT
#iptables -A INPUT -s 0/24 -d $ip_wan -p tcp --dport 22 -j ACCEPT
#iptables -A OUTPUT -s 0/24 -d $ip_wan  -p tcp --dport 22 -j ACCEPT
#iptables -A INPUT -s 0/24 -d $ip_wan  -p udp --dport 22 -j ACCEPT
#iptables -A OUTPUT -s 0/24 -d $ip_wan  -p udp --dport 22 -j ACCEPT

#----------------------------------------------#
#       POLACZENIA NAWIAZANE                   #
#----------------------------------------------#

iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED        # zaladowanie modulu(-m), uzycie modulu(--modul)
iptables -A FORWARD -j ACCEPT -m state --state ESTABLISHED,RELATED
iptables -A OUTPUT -j ACCEPT -m state --state ESTABLISHED,RELATED

#---------------DNS----------------------------#

iptables -A INPUT -s $dns_1 -p udp -sport 53 -j ACCEPT
iptables -A INPUT -s $dns_2 -p udp -sport 53 -j ACCEPT
iptables -A INPUT -s $dns_3 -p udp -sport 53 -j ACCEPT

#---------------FTP----------------------------#

iptables -t mangle -A POSTROUTING -m layer7 --l7proto ftp -j MARK --set-mark 01

#------------BITTORRENT------------------------#

iptables -t mangle -A POSTROUTING -m layer7 --l7proto bittorrent -j MARK --set-mark 001
iptables -t mangle -A POSTROUTING -m layer7 --l7proto ares -j MARK --set-mark 002

#--------------SSL-----------------------------#

iptables -t mangle -A POSTROUTING -m layer7 --l7proto ssl -j MARK --set-mark 02

#-------------HTTP-----------------------------#

iptables -t mangle -A POSTROUTING -m layer7 --l7proto http -j MARK --set-mark 03

#------------POCZTA----------------------------#

iptables -t mangle -A POSTROUTING -m layer7 --l7proto smtp -j MARK --set-mark 04
iptables -t mangle -A POSTROUTING -m layer7 --l7proto pop3 -j MARK --set-mark 05

#----------------------------------------------#
#                HOSTS CONFIG                  #
#----------------------------------------------#

#-------------NOX.XEEN.PL----------------------#
iptables -t nat -A POSTROUTING -s $u1 -j MASQUERADE
iptables -A FORWARD -m mac --mac-source $mu1 -j ACCEPT
#-----------PIETJA.XEEN.PL---------------------#
iptables -t nat -A POSTROUTING -s $u8 -j MASQUERADE
iptables -A FORWARD -m mac --mac-source $mu2 -j ACCEPT
#---------HOT_SZPROT.XEEN.PL-------------------#
iptables -t nat -A POSTROUTING -s $u2 -j MASQUERADE
iptables -A FORWARD -m mac --mac-source $mu3  -j ACCEPT

po wystartowaniu tego skryptu dostaje:

Kod:

root@nox:~# /etc/firewall/firewall
iptables v1.4.0: multiple -s flags not allowed
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.0: multiple -s flags not allowed
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.0: multiple -s flags not allowed
Try `iptables -h' or 'iptables --help' for more information.

i przestaje działac WWW, GG i inne rzeczy działaja.


[url=http://www.speedway.lublin.pl]http://speedway.lublin.pl[/url] || [url=http://xeen.wordpress.com]http://xeen.wordpress.com[/url] || [url=http://forum.unreal.pl]http://forum.unreal.pll[/url] || [url=http://carbonplast.eu]http://carbonplast.eu[/url]

Offline

 

#2  2008-05-05 18:14:14

  grzegorz.85 - Członek DUG

grzegorz.85
Członek DUG
Skąd: Ostrołęka
Zarejestrowany: 2007-07-12
Serwis

Re: Firewall - poprawki i pomoc w pisaniu

prorokuję problem z DNS, prorokiem jestem marnym, ale obstawiałbym zmianę:

Kod:

#---------------DNS----------------------------#

iptables -A INPUT -s $dns_1 -p udp -sport 53 -j ACCEPT
iptables -A INPUT -s $dns_2 -p udp -sport 53 -j ACCEPT
iptables -A INPUT -s $dns_3 -p udp -sport 53 -j ACCEPT

na

Kod:

#---------------DNS----------------------------#

iptables -A INPUT -s $dns_1 -p udp --dport 53 -j ACCEPT
iptables -A INPUT -s $dns_2 -p udp --dport 53 -j ACCEPT
iptables -A INPUT -s $dns_3 -p udp --dport 53 -j ACCEPT

Offline

 

#3  2008-05-09 16:34:27

  nox - Użytkownik

nox
Użytkownik
Skąd: Lublin
Zarejestrowany: 2008-03-19
Serwis

Re: Firewall - poprawki i pomoc w pisaniu

Ok dzieki, zaraz przetestuje. Mam natomiast inne pytanie. Nigdzie nie znalazlem wyjasnienia:
co mozna robic za pomoca : POSTROUNTING, PREROUTING kiedy stosowac do jakich uslug ( przykłaodowo)
oraz co mozna robic w tableach NAT i MANGLE
z góry dziekuje za odpowiedz


[url=http://www.speedway.lublin.pl]http://speedway.lublin.pl[/url] || [url=http://xeen.wordpress.com]http://xeen.wordpress.com[/url] || [url=http://forum.unreal.pl]http://forum.unreal.pll[/url] || [url=http://carbonplast.eu]http://carbonplast.eu[/url]

Offline

 

#4  2008-05-09 21:16:07

  siarka2107 - Użyszkodnik DUG

siarka2107
Użyszkodnik DUG
Skąd: Warszawa
Zarejestrowany: 2006-04-05

Re: Firewall - poprawki i pomoc w pisaniu

zajrzyj [url=http://www-users.mat.umk.pl/~minaq/iptables.pdf]tutaj[/url]

Offline

 

Stopka forum

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson
Możesz wyłączyć AdBlock — tu nie ma reklam ;-)

[ Generated in 0.009 seconds, 11 queries executed ]

Informacje debugowania

Time (s) Query
0.00010 SET CHARSET latin2
0.00007 SET NAMES latin2
0.00120 SELECT u.*, g.*, o.logged FROM punbb_users AS u INNER JOIN punbb_groups AS g ON u.group_id=g.g_id LEFT JOIN punbb_online AS o ON o.ident='3.145.33.235' WHERE u.id=1
0.00094 REPLACE INTO punbb_online (user_id, ident, logged) VALUES(1, '3.145.33.235', 1727601915)
0.00063 SELECT * FROM punbb_online WHERE logged<1727601615
0.00053 SELECT topic_id FROM punbb_posts WHERE id=90195
0.00126 SELECT id FROM punbb_posts WHERE topic_id=11371 ORDER BY posted
0.00068 SELECT t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, 0 FROM punbb_topics AS t INNER JOIN punbb_forums AS f ON f.id=t.forum_id LEFT JOIN punbb_forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id=11371 AND t.moved_to IS NULL
0.00006 SELECT search_for, replace_with FROM punbb_censoring
0.00100 SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online FROM punbb_posts AS p INNER JOIN punbb_users AS u ON u.id=p.poster_id INNER JOIN punbb_groups AS g ON g.g_id=u.group_id LEFT JOIN punbb_online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id=11371 ORDER BY p.id LIMIT 0,25
0.00092 UPDATE punbb_topics SET num_views=num_views+1 WHERE id=11371
Total query time: 0.00739 s