Benutzer-Werkzeuge

Webseiten-Werkzeuge


freebsd:freebsd_-_firewall

FreeBSD - Firewall

/etc/rc.firewall

#!/bin/sh
# 
######## Variablen werden definiert ########################################### 
NETDEV="fxp0"         # Netzwerk-Device
LIP="192.168.0.100"   # locale IP
############################################################################### 
#
######## Alle Rgeln werden geloescht (RESET) ################################## 
ipfw -f flush 
############################################################################### 
# 
######## Nicht-Routingfaehige IP's werden verboten (Spoofing) ################# 
ipfw add 1 deny log all from 127.0.0.0/8 to any in via $NETDEV 
#ipfw add 2 deny log all from 192.168.0.0/16 to any in via $NETDEV 
ipfw add 3 deny log all from 172.16.0.0/12 to any in via $NETDEV 
ipfw add 4 deny log all from 10.0.0.0/8 to any in via $NETDEV 
############################################################################### 
# 
######## Loopback erlauben #################################################### 
ipfw add 5 allow  all from any to any via lo0
ipfw add 6 deny log all from any to 127.0.0.0/8
############################################################################### 
#
######## "state-full-Paketfilter-Regeln" werden ermoeglicht ################### 
ipfw add 7 check-state 
############################################################################### 
# 
######## ermoeglicht die Einwahl per SSH von ueberall ######################### 
ipfw add 10 allow  tcp from any to any 22 keep-state
############################################################################### 
#
######## unterdrueckt jeden Ping von draussen. ################################ 
ipfw add 20 deny  icmp from any to $LIP icmptypes 8 
############################################################################### 
# 
######## unterdruecken bestimmten ICMP-Typen. ################################# 
ipfw add 40 deny  icmp from any to any icmptypes 3 out via $NETDEV
ipfw add 41 deny log icmp from any to any icmptypes 5 
ipfw add 42 deny  icmp from any to any icmptypes 15 
############################################################################### 
# 
######## der restlichen icmp-Verkehr wird erlaubt ############################# 
ipfw add 100 allow  icmp from any to any
############################################################################### 
# 
######## fuer FTP erforderlich ################################################ 
ipfw add 200 allow  tcp from any to any 21 keep-state
ipfw add 201 allow  udp from any to any 21 keep-state
############################################################################### 
#
######## NAMESERVER-Anfragen - erlauben ####################################### 
ipfw add 1000 allow  udp from any to any 53 keep-state 
############################################################################### 
# 
############################################################################### 
# Port    20  (tcp)      FTP    # Datenkanal 
# Port    21  (tcp)      FTP    # Verbindungsaufbau
# Port    22  (tcp)      SSH    # SSH ist oben general frei gemacht 
# Port    25  (tcp)      SMTP   # Server fuer raus gehende Mails 
# Port    53  (udp)      DNS    # Domain-Name-Services 
# Port    67  (udp)      DHCPS  # Bootstrap Protocol Server 
# Port    68  (udp)      DHCPC  # Bootstrap Protocol Client
# Port    80  (tcp)      HTTP   # unverschluesselte Verbindung ins Web 
# Port   110  (tcp)      POP    # Server fuer rein kommende Mails
# Port   123  (tcp/udp)  NTP    # NTP-Server siehe Regeln 11 und 12
# Port   443  (tcp)      HTTPS  # verschluesselte Verbindung ins Web
# Port  8080  (tcp/udp)  Proxy  # 
############################################################################### 
# 
######## aktualisieren der Uhrzeit mittels Network-Time-Protocol ############## 
ipfw add 1302 allow  tcp from any to any 123 keep-state
ipfw add 1303 allow  udp from any to any 123 keep-state
############################################################################### 
# 
######## fuer HTTP erforderlich ############################################### 
ipfw add 5000 allow  tcp from any to any 80 keep-state
############################################################################### 
# 
######## fuer HTTPS erforderlich ############################################## 
ipfw add 5020 allow  tcp from any to any 443 keep-state
############################################################################### 
# 
######## SMTP und POP3 ########################################################
ipfw add 5500 allow  tcp from any to any 25,110 keep-state 
ipfw add 6000 reset  tcp from any to any 113
###############################################################################
# 
######## unprivilegierte Ports oeffnen ########################################
ipfw add 6500 allow  tcp from any to any 1024-65535
###############################################################################
# 
######## Windoofs Ports oeffnen fuer samba ####################################
ipfw add 6550 allow  tcp from any to any 136-139
### die udp-Ports sind NICHT erforderlich #####################################
#ipfw add 6551 allow  udp from any to any 136-139
###############################################################################
# 
######## Drucker Port oeffnen #################################################
ipfw add 6555 allow  tcp from any to any 515 keep-state
###############################################################################
# 
######## Der Rest wird verboten ############################################### 
ipfw add 40000 deny  all from any to any 
############################################################################### 
/home/http/wiki/data/pages/freebsd/freebsd_-_firewall.txt · Zuletzt geändert: von manfred