Servus,
ich baue mir zz ein kleines Iptables-Script zusammen. Als Grundgerüst hab ich mir ein Script generieren lasse, das ich jetzt versuche an meine Bedürfnisse anzupassen. Nur leider klappt nichts alles so wie es soll:
Das Script sieht so aus:
Wenn ich das Script mit /etc/init.d/firewall start starten will kommt folgende Meldung:
Könntet ihr mir helfen?
mfg krumme
ich baue mir zz ein kleines Iptables-Script zusammen. Als Grundgerüst hab ich mir ein Script generieren lasse, das ich jetzt versuche an meine Bedürfnisse anzupassen. Nur leider klappt nichts alles so wie es soll:
Das Script sieht so aus:
Code:
exit 0
#!bin/sh
#####################################################
# IPTables Firewall-Skript #
# #
# erzeugt mit dem IPTables-Skript-Generator auf #
# tobias-bauer.de - Version 0.3 #
# URL: http://linux.tobias-bauer.de/iptables.html #
# #
# Autor: Tobias Bauer #
# E-Mail: exarkun@ist-root.org #
# #
# Das erzeugte Skript steht unter der GNU GPL! #
# #
# ACHTUNG! Die Benutzung des Skriptes erfolgt auf #
# eigene Gefahr! Ich übernehme keinerlei Haftung #
# für Schäden die durch dieses Skript entstehen! #
# #
#####################################################
# iptables suchen
iptables=`which iptables`
# wenn iptables nicht installiert abbrechen
test -f $iptables || exit 0
case "$1" in
start)
echo "Starte Firewall..."
# alle Regeln löschen
$iptables -t nat -F
$iptables -t filter -F
$iptables -X
# neue Regeln erzeugen
$iptables -N garbage
$iptables -I garbage -p TCP -j LOG --log-prefix="DROP TCP-Packet: " --log-level err
$iptables -I garbage -p UDP -j LOG --log-prefix="DROP UDP-Packet: " --log-level err
$iptables -I garbage -p ICMP -j LOG --log-prefix="DROP ICMP-Packet: " --log-level err
# Default Policy
$iptables -P INPUT DROP
$iptables -P OUTPUT DROP
$iptables -P FORWARD DROP
# über Loopback alles erlauben
$iptables -I INPUT -i lo -j ACCEPT
$iptables -I OUTPUT -o lo -j ACCEPT
#####################################################
# ausgehende Verbindungen
# Port 22
$iptables -I OUTPUT -o eth0 -p TCP --sport 1024:65535 --dport 22 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -I INPUT -i eth0 -p TCP --sport 22 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Port 80
$iptables -I OUTPUT -o eth0 -p TCP --sport 1024:65535 --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -I INPUT -i eth0 -p TCP --sport 80 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
#####################################################
# eingehende Verbindungen
# Port 12345
$iptables -I INPUT -i eth0 -p TCP --sport 1024:65535 --dport 12345 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -I OUTPUT -o eth0 -p TCP --sport 12345 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Port 80
$iptables -I INPUT -i eth0 -p TCP --sport 1024:65535 --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -I OUTPUT -o eth0 -p TCP --sport 80 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
#Port 55000
$iptables -I INPUT -i eth0 -p TCP --sport 1024:65535 --dport 55000 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -I OUTPUT -o eth0 -p TCP --sport 55000 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEP
#####################################################
# Erweiterte Sicherheitsfunktionen
# SynFlood
$iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT
# PortScan
$iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
# Ping-of-Death
$iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
#####################################################
# bestehende Verbindungen akzeptieren
$iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#####################################################
# Garbage übergeben wenn nicht erlaubt
$iptables -A INPUT -m state --state NEW,INVALID -j garbage
#####################################################
# alles verbieten was bisher erlaubt war
$iptables -A INPUT -j garbage
$iptables -A OUTPUT -j garbage
$iptables -A FORWARD -j garbage
;;
stop)
echo "Stoppe Firewall..."
$iptables -t nat -F
$iptables -t filter -F
$iptables -X
$iptables -P INPUT ACCEPT
$iptables -P OUTPUT ACCEPT
$iptables -P FORWARD ACCEPT
;;
restart|reload|force-reload)
$0 stop
$0 start
;;
*)
echo "Usage: /etc/init.d/firewall (start|stop)"
exit 1
;;
esac
exit 0
Wenn ich das Script mit /etc/init.d/firewall start starten will kommt folgende Meldung:
Code:
Starte Firewall...
iptables v1.3.6: Couldn't load target `ACCEP':/lib/iptables/libipt_ACCEP.so: cannot open shared object file: No such file or directory
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.3.6: Couldn't load target `ACCEP':/lib/iptables/libipt_ACCEP.so: cannot open shared object file: No such file or directory
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.3.6: Couldn't load target `ACCEP':/lib/iptables/libipt_ACCEP.so: cannot open shared object file: No such file or directory
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.3.6: Couldn't load target `ACCEP':/lib/iptables/libipt_ACCEP.so: cannot open shared object file: No such file or directory
Try `iptables -h' or 'iptables --help' for more information.
Könntet ihr mir helfen?
mfg krumme