Shorewall: Unterschied zwischen den Versionen

Aus crazylinux.de
Zur Navigation springen Zur Suche springen
(zone fixes)
K (x)
 
(4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
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)
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.  
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
</pre>  
</pre>
/etc/shorewall/policy (für das 'Normalverhalten')  
 
<pre>###############################################################################
/etc/shorewall/policy (für das 'Normalverhalten')
<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>#ZONE  TYPE            OPTIONS        IN                      OUT
<pre>
 
#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>


/etc/shorewall/accounting
# Drop Ping from the "bad" net zone.. and prevent your log from being flooded..
<pre>
#Ping(DROP)    net            $FW
#####################################################################################
 
# Permit all ICMP traffic FROM the firewall TO the net zone
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
mail            -      eth0    -              tcp            25,993,995
mail            -      eth0    -              tcp            25,993,995
mail            -      -      eth0            tcp            -              25,993,995
mail            -      -      eth0            tcp            -              25,993,995
mail            -      -      eth0            tcp            25,993,995
COUNT          mail    eth0
COUNT          mail    eth0
COUNT          mail    -      eth0
COUNT          mail    -      eth0
ftp            -      eth0    -              tcp            21
 
ftp            -      -      eth0            tcp            -              21
ssh            -      eth0    -              tcp            22,563
ssh            -      -      eth0            tcp            -              22,563
COUNT          ssh    eth0
COUNT          ssh    -      eth0
 
ftp            -      eth0    -              tcp            21,20,33000:33100
ftp            -      -      eth0            tcp            -              21,20,33000:33100
COUNT          ftp    eth0
COUNT          ftp    eth0
COUNT          ftp    -      eth0
COUNT          ftp    -      eth0
stream            -      eth0    -              tcp            8000,8001
stream            -      eth0    -              tcp            8000,8001
stream            -      -      eth0            tcp            -              8000,8001
stream            -      -      eth0            tcp            -              8000,8001
COUNT          stream    eth0
COUNT          stream    eth0
COUNT          stream    -      eth0
COUNT          stream    -      eth0
web            -      eth0    -              tcp            80
 
web            -      -      eth0            tcp            -              80
web            -      eth0    -              tcp            80,443
web            -      eth0    -              tcp            443
web            -      -      eth0            tcp            -              80,443
web            -      -      eth0            tcp            -              443
COUNT          web    eth0
COUNT          web    eth0
COUNT          web    -      eth0
COUNT          web    -      eth0
</pre>


dns            -      eth0    -              udp            -      53
dns            -      -      eth0            udp            53
COUNT          dns    eth0
COUNT          dns    -      eth0
countall                -      eth0
countall                -      -      eth0
COUNT          countall        eth0
COUNT          countall        -      eth0
backup:COUNT            -      eth0  188.xx.xx.xx              tcp  -      -
backup:COUNT            -      188.xx.xx.xx      eth0            tcp -      -
DONE    backup
</pre>
==== Betrieb  ====


=Betrieb=
ein


ein
  shorewall check
  shorewall check
prüft die Konfig, ein
 
prüft die Konfig, ein  
 
  shorewall start
  shorewall start
startet das ganze.


startet das ganze.


=IP-Adressen blocken=
<br>
Sind mal wieder böse Leute im Netz unterwegs, kann man diese einfach sperren, bzw. droppen:
 
shorewall drop 61.129.57.x
==== 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


[[Category:Linux]]
[[Category:Linux]]

Aktuelle Version vom 19. August 2012, 23:07 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

/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
mail             -       -       eth0            tcp             25,993,995
COUNT           mail     eth0
COUNT           mail     -       eth0

ssh             -       eth0    -               tcp             22,563
ssh             -       -       eth0            tcp             -               22,563
COUNT           ssh     eth0
COUNT           ssh     -       eth0

ftp             -       eth0    -               tcp             21,20,33000:33100
ftp             -       -       eth0            tcp             -               21,20,33000:33100
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,443
web             -       -       eth0            tcp             -               80,443
COUNT           web     eth0
COUNT           web     -       eth0

dns             -       eth0    -               udp             -       53
dns             -       -       eth0            udp             53
COUNT           dns     eth0
COUNT           dns     -       eth0

countall                -       eth0
countall                -       -       eth0
COUNT           countall        eth0
COUNT           countall        -       eth0

backup:COUNT             -       eth0   188.xx.xx.xx               tcp  -       -
backup:COUNT             -       188.xx.xx.xx       eth0            tcp -       -
DONE    backup

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