Shorewall: Unterschied zwischen den Versionen

Aus crazylinux.de
Zur Navigation springen Zur Suche springen
(zone fixes)
K (setup)
Zeile 2: Zeile 2:
als Firewall wird shorewall (mit iptables/netfilter) verwendet.
als Firewall wird shorewall (mit iptables/netfilter) verwendet.


=Konfiguration=
= Konfiguration =
nach der Installation wird entsprechend konfiguriert. Folgendes geändert, der Rest default.


/etc/default/shorewall
nach der Installation wird entsprechend konfiguriert. Folgendes geändert, der Rest default.
<pre>
 
# prevent startup with default configuration
/etc/default/shorewall  
<pre># prevent startup with default configuration
# set the below varible to 1 in order to allow shorewall to start
# set the below varible to 1 in order to allow shorewall to start
startup=1
startup=1
</pre>
</pre>  
 
/etc/shorewall/shorewall.conf  
/etc/shorewall/shorewall.conf
<pre>#IP_FORWARDING=off
<pre>
#DISABLE_IPV6=yes
IP_FORWARDING=off
</pre>  
DISABLE_IPV6=yes
/etc/shorewall/interfaces  
</pre>
<pre>##############################################################################
 
/etc/shorewall/interfaces
<pre>
##############################################################################
#ZONE    INTERFACE      BROADCAST      OPTIONS
#ZONE    INTERFACE      BROADCAST      OPTIONS
net    eth0            detect          dhcp,routefilter,norfc1918,tcpflags
net    eth0            detect          tcpflags,logmartians,nosmurfs
#LAST LINE -- DO NOT REMOVE
#LAST LINE -- DO NOT REMOVE
</pre>
</pre>  
 
/etc/shorewall/policy (für das 'Normalverhalten')  
/etc/shorewall/policy (für das 'Normalverhalten')
<pre>###############################################################################
<pre>
###############################################################################
#SOURCE        DEST            POLICY          LOG            LIMIT:BURST
#SOURCE        DEST            POLICY          LOG            LIMIT:BURST
fw              all             ACCEPT
$FW            net             ACCEPT
all             all            REJECT
net             all            DROP            #info
#                                               LEVEL
# The FOLLOWING POLICY MUST BE LAST
#LAST LINE -- DO NOT REMOVE
all            all            REJECT          #info
</pre>
</pre>  
 
/etc/shorewall/zones  
/etc/shorewall/zones
<pre>
<pre>
#ZONE  TYPE            OPTIONS        IN                      OUT
#ZONE  TYPE            OPTIONS        IN                      OUT
#                                      OPTIONS                OPTIONS
#                                      OPTIONS                OPTIONS
fw      firewall
fw      firewall
net    ipv4
net    ipv4
#loc    ipv4
</pre>  
vwn    ipv4
/etc/shorewall/rules (was wir explizit erlauben wollen)  
#LAST LINE - ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
<pre>####################################################################################################
</pre>
 
/etc/shorewall/rules (was wir explizit erlauben wollen)
<pre>
####################################################################################################
#ACTION  SOURCE        DEST            PROTO  DEST    SOURCE    ORIGINAL    RATE            USER/
#ACTION  SOURCE        DEST            PROTO  DEST    SOURCE    ORIGINAL    RATE            USER/
#                                              PORT    PORT(S)    DEST        LIMIT          GROUP
#                                              PORT    PORT(S)    DEST        LIMIT          GROUP
#ACCEPT          all            fw              tcp    563
SECTION NEW
ACCEPT          all            fw              tcp    22
 
ACCEPT          all            fw              tcp    563
#ACCEPT          all            fw              tcp    22
ACCEPT          all            fw              tcp    443
ACCEPT          all            fw              tcp    443
ACCEPT          all            fw              tcp    80
ACCEPT          all            fw              tcp    80
#ACCEPT          all            fw              tcp    110
ACCEPT          all            fw              tcp    25
ACCEPT          all            fw              tcp    25
ACCEPT          all            fw              tcp    993
ACCEPT          all            fw              tcp    993
ACCEPT          all            fw              tcp    995
ACCEPT          all            fw              tcp    995
AllowPing   all      fw
Ping(ACCEPT)   all      fw
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
 
</pre>
# Drop Ping from the "bad" net zone.. and prevent your log from being flooded..
#Ping(DROP)    net            $FW


/etc/shorewall/accounting
# Permit all ICMP traffic FROM the firewall TO the net zone
<pre>
ACCEPT          $FW            net            icmp
#####################################################################################
</pre>
/etc/shorewall/accounting  
<pre>#####################################################################################
#ACTION CHAIN  SOURCE          DESTINATION    PROTO  DEST            SOURCE  USER/
#ACTION CHAIN  SOURCE          DESTINATION    PROTO  DEST            SOURCE  USER/
#                                                      PORT(S)        PORT(S) GROUP
#                                                      PORT(S)        PORT(S) GROUP
Zeile 89: Zeile 80:
COUNT          web    -      eth0
COUNT          web    -      eth0
</pre>
</pre>


=Betrieb=
=Betrieb=

Version vom 19. August 2012, 22:58 Uhr

Ziel, alles von aussen sperren, nach innen nur 'named' port, wie z.b. 22(ssh),25(smtp),80(http),443(https),993(imaps),995(pop3s) als Firewall wird shorewall (mit iptables/netfilter) verwendet.

Konfiguration

nach der Installation wird entsprechend konfiguriert. Folgendes geändert, der Rest default.

/etc/default/shorewall

# prevent startup with default configuration
# set the below varible to 1 in order to allow shorewall to start
startup=1

/etc/shorewall/shorewall.conf

#IP_FORWARDING=off
#DISABLE_IPV6=yes

/etc/shorewall/interfaces

##############################################################################
#ZONE    INTERFACE      BROADCAST       OPTIONS
net     eth0            detect          tcpflags,logmartians,nosmurfs
#LAST LINE -- DO NOT REMOVE

/etc/shorewall/policy (für das 'Normalverhalten')

###############################################################################
#SOURCE         DEST            POLICY          LOG             LIMIT:BURST
$FW             net             ACCEPT
net             all             DROP            #info
# The FOLLOWING POLICY MUST BE LAST
all             all             REJECT          #info

/etc/shorewall/zones

#ZONE   TYPE            OPTIONS         IN                      OUT
#                                       OPTIONS                 OPTIONS
fw      firewall
net     ipv4

/etc/shorewall/rules (was wir explizit erlauben wollen)

####################################################################################################
#ACTION  SOURCE         DEST            PROTO   DEST    SOURCE     ORIGINAL     RATE            USER/
#                                               PORT    PORT(S)    DEST         LIMIT           GROUP
SECTION NEW

ACCEPT          all             fw              tcp     563
#ACCEPT          all             fw              tcp     22
ACCEPT          all             fw              tcp     443
ACCEPT          all             fw              tcp     80
ACCEPT          all             fw              tcp     25
ACCEPT          all             fw              tcp     993
ACCEPT          all             fw              tcp     995
Ping(ACCEPT)    all       fw

# Drop Ping from the "bad" net zone.. and prevent your log from being flooded..
#Ping(DROP)     net             $FW

# Permit all ICMP traffic FROM the firewall TO the net zone
ACCEPT          $FW             net             icmp

/etc/shorewall/accounting

#####################################################################################
#ACTION CHAIN   SOURCE          DESTINATION     PROTO   DEST            SOURCE  USER/
#                                                       PORT(S)         PORT(S) GROUP
mail             -       eth0    -               tcp             25,993,995
mail             -       -       eth0            tcp             -               25,993,995
COUNT           mail     eth0
COUNT           mail     -       eth0
ftp             -       eth0    -               tcp             21
ftp             -       -       eth0            tcp             -               21
COUNT           ftp     eth0
COUNT           ftp     -       eth0
stream             -       eth0    -               tcp             8000,8001
stream             -       -       eth0            tcp             -               8000,8001
COUNT           stream     eth0
COUNT           stream     -       eth0
web             -       eth0    -               tcp             80
web             -       -       eth0            tcp             -               80
web             -       eth0    -               tcp             443
web             -       -       eth0            tcp             -               443
COUNT           web     eth0
COUNT           web     -       eth0

Betrieb

ein

shorewall check

prüft die Konfig, ein

shorewall start

startet das ganze.


IP-Adressen blocken

Sind mal wieder böse Leute im Netz unterwegs, kann man diese einfach sperren, bzw. droppen:

shorewall drop 61.129.57.x