Hey,
hier n kleines Skript zur bequemeren Konfiguration von iptables unter Ubuntu.
Hier das Konfigurationsskript:
/etc/iptables.sh
#!/bin/sh
# Iptables
FW=”/sbin/iptables”
# vorhandene Regeln & Ketten löschen
$FW -F
$FW -X
$FW -t nat -F
# Standardregeln
$FW -P INPUT ACCEPT
$FW -P FORWARD ACCEPT
$FW -P OUTPUT ACCEPT
$FW -A INPUT -p tcp –dport www -s xxx.xx.xx.x/16 -j ACCEPT
$FW -A INPUT -p tcp –dport www -j DROP
$FW -A INPUT -p tcp –dport https -s xxx.xx.xx.x/16 -j ACCEPT
$FW -A INPUT -p tcp –dport https -j DROP
$FW -A INPUT -p tcp –dport ssh -s xxx.xx.xx.xxx -j ACCEPT
$FW -A INPUT -p tcp –dport ssh -s xxx.xx.xx.xxx -j ACCEPT
$FW -A INPUT -p tcp –dport ssh -s xxx.xx.xx.xxx -j ACCEPT
$FW -A INPUT -p tcp –dport ssh -s xxx.xx.xx.xxx -j ACCEPT
$FW -A INPUT -p tcp –dport ssh -s xxx.xx.xx.xxx -j ACCEPT
$FW -A INPUT -p tcp –dport ssh -s xxx.xx.xx.xxx -j ACCEPT
$FW -A INPUT -p tcp –dport ssh -j DROP
$FW -A INPUT -p tcp –dport 21 -s xxx.xx.xx.xxx -j ACCEPT
$FW -A INPUT -p tcp –dport 21 -j DROP
$FW -A INPUT -p tcp –dport 7777 -s xxx.xx.xx.xxx -j ACCEPT
$FW -A INPUT -p tcp –dport 7777 -j DROP
Hier das Init-Skript:
/etc/init.d/firewall
#!/bin/sh
### BEGIN INIT INFO
# Provides: iptables
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $syslog
# Should-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start or stop the firewall daemon.
### END INIT INFO
. /lib/lsb/init-functions
case “$1” in
start)
/etc/iptables.sh
iptables -L
;;
stop)
iptables -F
iptables -X
iptables -L
;;
status)
iptables -L
;;
*)
echo “Usage: /etc/init.d/firewall {start|stop|status}”
exit 1
;;
esac
exit 0
Automatisches Laden des Skripts in den Default-Runlevels:
update-rc.d firewall defaults