aboutsummaryrefslogtreecommitdiff
path: root/firewall.mdwn
blob: a76a114b84327b62ba25ed2ff33873e2b8237f55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
[[!toc levels=4]]

Configura��o do shorewall 
=========================

De in�cio, instale o shorewall:

    apt-get install shorewall

� necess�rio que o iptables esteja configurado para encaminhar os pacotes de uma porta externa para os vservers. As seguinte diretiva precisa ser alterada na configura��o original no arquivo `/etc/shorewall/shorewall.conf`:

    IP_FORWARDING=Yes

O arquivo `/etc/shorewall/interfaces` deve conter a interface de rede:

    #ZONE   INTERFACE       BROADCAST       OPTIONS
    - eth0 detect tcpflags,blacklist,routefilter,nosmurfs,logmartians,norfc1918
    #LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE

O arquivo `/etc/shorewall/zones` deve conter as zonas da rede:

    ###############################################################################
    #ZONE   TYPE            OPTIONS         IN                      OUT
    #                                       OPTIONS                 OPTIONS
    fw      firewall
    vm      ipv4
    net     ipv4
    #LAST LINE - ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE

O arquivo `/etc/shorewall/hosts` associa zonas a subredes:

    #ZONE   HOST(S)                                 OPTIONS
    vm      eth0:192.168.0.0/24
    net     eth0:0.0.0.0/0
    #LAST LINE -- ADD YOUR ENTRIES BEFORE THIS LINE -- DO NOT REMOVE

O arquivo `/etc/shorewall/policy` define as regras para tr�fego de pacotes:

    ###############################################################################
    #SOURCE         DEST            POLICY          LOG             LIMIT:BURST
    #                                               LEVEL
    vm              net             ACCEPT
    $FW             net             ACCEPT
    $FW             vm              ACCEPT
    net             all             DROP            info
    # THE FOLLOWING POLICY MUST BE LAST
    all             all             REJECT          info
    #LAST LINE -- DO NOT REMOVE

E o arquivo `/etc/shorewall/rules` define exce��es �s regras gerais:

    ################################################################
    #ACTION         SOURCE          DEST            PROTO   DEST
    SSH/ACCEPT      net             $FW
    Ping/ACCEPT     net             $FW
    HTTP/ACCEPT     net             $FW
    HTTPS/ACCEPT    net             $FW
    #LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE

Adicionamos m�scaras NAT aos pacotes da rede interna atrav�s do `/etc/shorewall/masq`:

    ###############################################################################
    #INTERFACE              SOURCE          ADDRESS         PROTO   PORT(S) IPSEC   MARK
    eth0:!192.168.0.0/24    192.168.0.0/24
    #LAST LINE -- ADD YOUR ENTRIES ABOVE THIS LINE -- DO NOT REMOVE

Habilite o shorewall mudando o valor de startup de `/etc/default/shorewall` para `1`:

    startup=1

Finalmente podemos ligar o shorewall:

    /etc/init.d/shorewall start

Shorewall e Puppet 
==================

Uma vez que um nodo [puppetmaster](../puppet) estiver rodando, o m�dulo [puppet-shorewall](http://git.sarava.org/?p=puppet-shorewall.git;a=summary) poder� ser utilizado para gerenciar o firewall. No entanto, se voc� for substituir o presente procedimento pela sua vers�o via puppet, certifique-se de apagar os arquivos `/etc/shorewall/{masq,policy,zones,rules,interfaces}`.