einherjer
07.06.02, 13:11
Ich hab mir mal für meinen Fall (Rechner mit fixer IP, Zugang über SSH, kein FTP Server -> SCP, IMAP Server, DNS, Webmin auf anderem Port) ein Script zusammengebastelt. Ist aus verschiedenen anderen zusammengeklaut weil ich nicht DIE Ahnung von Firewalls hab :rolleyes:
Wäre nett wenn ihr Euch das mal ansehen könntet ob ich da noch schwerwiegende Fehler drin hab...
>>>>-------
# !/bin/sh
#
# ----- IP TABLES / FIREWALL ----
#
iptables=/usr/sbin/iptables
# Benoetigte Module hinzufuegen
/sbin/modprobe ip_conntrack
# Zuruecksetzen aller Regeln
$iptables -F
$iptables -P INPUT DROP
$iptables -P FORWARD DROP
$iptables -P OUTPUT DROP
# Alle bereits bestehenden Verbindungen erlauben
$iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -I OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Erlauben von PING
$iptables -A INPUT -m limit -p ICMP --limit 1 --limit-burst 2 -j ACCEPT
$iptables -A OUTPUT -m limit -p ICMP --limit 1 --limit-burst 2 -j ACCEPT
# Erlauben von Loopback-Verbindungen
$iptables -A INPUT -i lo -j ACCEPT
$iptables -A OUTPUT -o lo -j ACCEPT
#Erlauben von FTP (Client)
$iptables -A OUTPUT -p tcp --dport 21 -j ACCEPT
#Erlauben von SSH (Server und Client)
$iptables -A INPUT -p tcp --dport 22 -j ACCEPT
$iptables -A OUTPUT -p tcp --dport 22 -j ACCEPT
# Erlauben von DNS
$iptables -A OUTPUT -p udp --sport 1024: --dport 53 -j ACCEPT
$iptables -A OUTPUT -p tcp --sport 1024: --dport 53 -j ACCEPT
$iptables -A INPUT -p udp -s 195.20.224.97 --sport 53 -j ACCEPT
$iptables -A INPUT -p tcp -s 195.20.224.97 --sport 53 -j ACCEPT
$iptables -A INPUT -p udp --sport 53 --dport 7531 -j ACCEPT
$iptables -A INPUT -p tcp --sport 53 --dport 7531 -j ACCEPT
#Erlauben von HTTP (Server und Client)
$iptables -A INPUT -p tcp --dport 80 -j ACCEPT
$iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
#Erlauben von ident
$iptables -A INPUT -p tcp --dport 113 -j ACCEPT -m limit --limit 2 --limit-burst 4
$iptables -A OUTPUT -p tcp --dport 113 -j ACCEPT -m limit --limit 2 --limit-burst 4
#Erlauben von IMAP (Server und Client)
$iptables -A INPUT -p tcp --dport 143 -j ACCEPT
$iptables -A OUTPUT -p tcp --dport 143 -j ACCEPT
#Erlauben von HTTPS (Server und Client)
$iptables -A INPUT -p tcp --dport 443 -j ACCEPT
$iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
#Erlauben von Webmin (auf port 7575)
$iptables -A INPUT -p tcp --dport 7575 -j ACCEPT
$iptables -A OUTPUT -p tcp --dport 7575 -j ACCEPT
Thx,
Wäre nett wenn ihr Euch das mal ansehen könntet ob ich da noch schwerwiegende Fehler drin hab...
>>>>-------
# !/bin/sh
#
# ----- IP TABLES / FIREWALL ----
#
iptables=/usr/sbin/iptables
# Benoetigte Module hinzufuegen
/sbin/modprobe ip_conntrack
# Zuruecksetzen aller Regeln
$iptables -F
$iptables -P INPUT DROP
$iptables -P FORWARD DROP
$iptables -P OUTPUT DROP
# Alle bereits bestehenden Verbindungen erlauben
$iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -I OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Erlauben von PING
$iptables -A INPUT -m limit -p ICMP --limit 1 --limit-burst 2 -j ACCEPT
$iptables -A OUTPUT -m limit -p ICMP --limit 1 --limit-burst 2 -j ACCEPT
# Erlauben von Loopback-Verbindungen
$iptables -A INPUT -i lo -j ACCEPT
$iptables -A OUTPUT -o lo -j ACCEPT
#Erlauben von FTP (Client)
$iptables -A OUTPUT -p tcp --dport 21 -j ACCEPT
#Erlauben von SSH (Server und Client)
$iptables -A INPUT -p tcp --dport 22 -j ACCEPT
$iptables -A OUTPUT -p tcp --dport 22 -j ACCEPT
# Erlauben von DNS
$iptables -A OUTPUT -p udp --sport 1024: --dport 53 -j ACCEPT
$iptables -A OUTPUT -p tcp --sport 1024: --dport 53 -j ACCEPT
$iptables -A INPUT -p udp -s 195.20.224.97 --sport 53 -j ACCEPT
$iptables -A INPUT -p tcp -s 195.20.224.97 --sport 53 -j ACCEPT
$iptables -A INPUT -p udp --sport 53 --dport 7531 -j ACCEPT
$iptables -A INPUT -p tcp --sport 53 --dport 7531 -j ACCEPT
#Erlauben von HTTP (Server und Client)
$iptables -A INPUT -p tcp --dport 80 -j ACCEPT
$iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
#Erlauben von ident
$iptables -A INPUT -p tcp --dport 113 -j ACCEPT -m limit --limit 2 --limit-burst 4
$iptables -A OUTPUT -p tcp --dport 113 -j ACCEPT -m limit --limit 2 --limit-burst 4
#Erlauben von IMAP (Server und Client)
$iptables -A INPUT -p tcp --dport 143 -j ACCEPT
$iptables -A OUTPUT -p tcp --dport 143 -j ACCEPT
#Erlauben von HTTPS (Server und Client)
$iptables -A INPUT -p tcp --dport 443 -j ACCEPT
$iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
#Erlauben von Webmin (auf port 7575)
$iptables -A INPUT -p tcp --dport 7575 -j ACCEPT
$iptables -A OUTPUT -p tcp --dport 7575 -j ACCEPT
Thx,