Direkt zum Hauptbereich

iptables - setting up a decent firewall

Here is nothing else to write about but the source code you put into /etc/init.d/firewall as a 755 script, and a ". /etc/init.d/firewall" line in to /etc/rc.local".

I adjusted some stuff reading through Eric Ambergs "Linux-Server" book.


 #!/bin/sh  
 echo "Initialisiere Firewall iptables ..."  
   
 # Firewallregeln löschen  
 iptables -F  
 iptables -X  
 iptables -P INPUT DROP  
 iptables -P OUTPUT DROP  
 iptables -P FORWARD DROP  
 iptables -Z  
   
 # Module laden für FTP ports  
 modprobe ip_conntrack_ftp  
   
 #------------------------------------------------------------------------------  
 # 
 # http://wiki.debianforum.de/Einfaches_Firewall-Script  
 #  
 # Logging options.  
 LOG="LOG --log-level 4 --log-tcp-sequence --log-tcp-options"  
 LOG="$LOG --log-ip-options"  
    
 # Defaults for rate limiting  
 RLIMIT="-m limit --limit 3/s --limit-burst 30"  
   
 # Custom user-defined chains.  
    
 # LOG packets, then ACCEPT.  
 iptables -N ACCEPTLOG  
 iptables -A ACCEPTLOG -j $LOG $RLIMIT --log-prefix "FW-ACCEPT: "  
 iptables -A ACCEPTLOG -j ACCEPT  
    
 # LOG packets, then DROP.  
 iptables -N DROPLOG  
 iptables -A DROPLOG -j $LOG $RLIMIT --log-prefix "FW-DROP: "  
 iptables -A DROPLOG -j DROP  
   
 # better not to REJECT anything for it tells somebody something  
 # LOG packets, then REJECT.  
 # TCP packets are rejected with a TCP reset.  
 iptables -N REJECTLOG  
 iptables -A REJECTLOG -j $LOG $RLIMIT --log-prefix "FW-REJECT: "  
 iptables -A REJECTLOG -p tcp -j REJECT --reject-with tcp-reset  
 iptables -A REJECTLOG -j REJECT  
   
 # Only allows RELATED ICMP types  
 # (destination-unreachable, time-exceeded, and parameter-problem).  
 # TODO: Rate-limit this traffic?  
 # TODO: Allow fragmentation-needed?  
 # TODO: Test.  
 iptables -N RELATED_ICMP  
 iptables -A RELATED_ICMP -p icmp --icmp-type destination-unreachable -j ACCEPT  
 iptables -A RELATED_ICMP -p icmp --icmp-type time-exceeded -j ACCEPT  
 iptables -A RELATED_ICMP -p icmp --icmp-type parameter-problem -j ACCEPT  
 iptables -A RELATED_ICMP -j DROPLOG  
    
 # Make It Even Harder To Multi-PING  
 iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 2 -j ACCEPT  
 iptables -A OUTPUT -p icmp -j ACCEPT  
    
 # Only allow the minimally required/recommended parts of ICMP. Block the rest.  
 #------------------------------------------------------------------------------  
    
 # Allow all ESTABLISHED ICMP traffic.  
 iptables -A INPUT -p icmp -m state --state ESTABLISHED -j ACCEPT $RLIMIT  
 iptables -A OUTPUT -p icmp -m state --state ESTABLISHED -j ACCEPT $RLIMIT  
    
 # Allow some parts of the RELATED ICMP traffic, block the rest.  
 iptables -A INPUT -p icmp -m state --state RELATED -j RELATED_ICMP $RLIMIT  
 iptables -A OUTPUT -p icmp -m state --state RELATED -j RELATED_ICMP $RLIMIT  
    
 # Allow incoming ICMP echo requests (ping), but only rate-limited.  
 iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT $RLIMIT  
    
 # Allow outgoing ICMP echo requests (ping), but only rate-limited.  
 iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT $RLIMIT  
    
 # Drop any other ICMP traffic.  
 iptables -A INPUT -p icmp -j DROPLOG  
 iptables -A OUTPUT -p icmp -j DROPLOG  
 iptables -A FORWARD -p icmp -j DROPLOG  
 #------------------------------------------------------------------------------  
   
 # loopback  
 iptables -A INPUT -i lo -j ACCEPT  
 iptables -A OUTPUT -o lo -j ACCEPT  
   
 # stateful inspection  
 iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT  
 iptables -A INPUT -m state --state INVALID -j DROPLOG  
 iptables -A OUTPUT -m state --state INVALID -j DROP  
 iptables -A FORWARD -m state --state INVALID -j DROP  
 iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT  
   
 # SSH  
 iptables -A INPUT -p tcp --dport 22 -j ACCEPTLOG  
   
 # DNS  
 iptables -A OUTPUT -m state --state NEW -p udp --dport 53 -j ACCEPT  
 iptables -A OUTPUT -m state --state NEW -p tcp --dport 53 -j ACCEPT  
 iptables -A INPUT -m state --state NEW -p udp --dport 53 -j ACCEPT  
 iptables -A INPUT -m state --state NEW -p tcp --dport 53 -j ACCEPT  
   
 # http  
 iptables -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT  
 iptables -A OUTPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT  
   
 # https  
 iptables -A INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT  
 iptables -A OUTPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT  
   
 #  
 # mail  
 #  
 # Erlaube eingehende SMTP Anfragen.  
 iptables -A INPUT -m state --state NEW -p tcp --dport 25 -j ACCEPT  
 # Erlaube ausgehende SMTP Anfragen.  
 iptables -A OUTPUT -m state --state NEW -p tcp --dport 25 -j ACCEPT  
 # Erlaube ausgehende SMTPS Anfragen.  
 iptables -A OUTPUT -m state --state NEW -p tcp --dport 465 -j ACCEPT  
   
 # Erlaube eingehende POP3 Anfragen.  
 iptables -A INPUT -m state --state NEW -p tcp --dport 110 -j ACCEPT  
 # Erlaube eingehende POP3S Anfragen.  
 iptables -A INPUT -m state --state NEW -p tcp --dport 995 -j ACCEPT  
    
 # Erlaube eingehende und ausgehendeIMAP4 Anfragen.
iptables -A INPUT -m state --state NEW -p tcp --dport 143 -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED -p tcp --dport 143 -j ACCEPT

# Erlaube eingehende und ausgehende IMAPS Anfragen.
iptables -A INPUT -m state --state NEW -p tcp --dport 993 -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED -p tcp --dport 993 -j ACCEPT
 
   
 # FTP  
 iptables -A OUTPUT -m state --state NEW -p tcp --dport 21 -j ACCEPT  
 iptables -A INPUT -m state --state NEW -p tcp --dport 21 -j ACCEPT  
   
 # Erlaube ausgehende NTP Anfragen.  
 iptables -A OUTPUT -m state --state NEW -p udp --dport 123 -j ACCEPT  
   
 # Erlaube ausgehende WHOIS Anfragen.  
 iptables -A OUTPUT -m state --state NEW -p tcp --dport 43 -j ACCEPT  
   
   
 # Explicitly log and reject everything else.  
 #------------------------------------------------------------------------------  
 # Use REJECT instead of REJECTLOG if you don't need/want logging. better DROPLOG!  
 iptables -A INPUT -j DROPLOG  
 iptables -A OUTPUT -j DROPLOG  
 iptables -A FORWARD -j DROPLOG  
    
 # Exit gracefully.  
 #------------------------------------------------------------------------------  
   
 echo "Firewall konfiguriert und aktiv."  
    
 exit 0  

Kommentare

Beliebte Posts aus diesem Blog

Pflanzsack aus Jute

Nachdem ich die Bücher vom Arche Noah Verein schon vorstellte, möchte ich hier eine Topfalternative zeigen, die obendrein noch dekorativ ist. Pflanzsäcke Oder "grow bags", wenn man etwas moderner daher komme möchte bzw. mehr Suchergenisse will. Dabei wollte ich wenig Geld ausgeben, und auch nicht ganz spartan bleiben und den Blumenerdesack dafür nutzen; und bestellte mir 50 kg Jutesäcke für ca. 1,20 EUR/Stück. Nimmt man den ganzen Sack, wird der Topf schon recht groß, auch wenn man etwas des Materials nach innen oder außen faltet. Also nahm ich mir die Freiheit und nähte aus einem großen vier kleine und verbrauchte den letzten Rest unserer Erde fürs Umtopfen der Habanero. Die machte nämlich nun Platz für die sibirische Hauschili und die restlichen von beiden Sorten mischte ich zusammen und stellte sie auf die Fensterbank. Der Vorteil dieser Art von Töpfen liegt auf der Hand: sie sind billig im Vergleich zum Volumen sie sind dekorativ - wirken rustikal biet

Zuhause fast "richtig" wok-en

Vor sehr vielen Jahren, ich war noch ein Jugendlicher, wuenschte ich mir einen Wok und bekam diesen dann auch. Es war ein gusseisener Wok, also eine schwere Ausfuehrung, der aber leider uneben und somit schwer zu gebrauchen war. Meine Eltern und ich gingen dann zurueck ins Geschaeft, aber ebene Woks waren mir damals zu teuer. Nun wieder viele Jahre in die Zukunft bekam ich die Idee, doch wieder den Wok-Gedanken aufzugreifen, denn wir kochen und essen viel asiatisch. Leider sind wir deutsche nicht so bevorteilt wie die Englaender, welche mit Gas kochen. Und ein Wok auf nem E-Herd ist so sexy wie Tanz in Gummistiefeln. Es stellte sich die Frage, inwieweit ich einen Gaskocher in die Wohnung bekomme und betreiben kann. Und solltest Du danach im Internet suchen, so wirst Du feststellen, dass man fuer ein richtiges Set mit mehr als 6 kW Leistung zwischen 50 und 600 EUR bezahlen kann, vom einfachen Hockerkocher bis zum Edelstahl-Hochleistungskocher. Mit Gas kochen ist einfach etwas wu

Herrlich!

Peter Rütten synchronisiert Lanz und Wowereit: