#!/bin/sh
#
# Version: 0.1
# Date: 29.10.2011
#
################################################################################

# IPTABLES
IPTABLES=/sbin/iptables
SYSCTL=/usr/sbin/sysctl

#MODPROBE=/usr/sbin/modprobe
#$MODPROPE ip_conntrack_ftp
#$MODPROBE ip_nat_ftp

$IPTABLES -F

$IPTABLES -P INPUT ACCEPT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT

################################################################################

$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A INPUT -p icmp -m icmp --icmp-type destination-unreachable -j REJECT --reject-with icmp-host-prohibited
$IPTABLES -A INPUT -i lo -j ACCEPT
$IPTABLES -A INPUT -p icmp -j ACCEPT

################################################################################

# DNS
$IPTABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -m udp -p udp --dport 53 -j ACCEPT

# FTP
$IPTABLES -A INPUT -m state --state NEW -p tcp --dport 21 -m state --state NEW -j ACCEPT

# SSH
$IPTABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

# HTTP
$IPTABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

# HTTPS
$IPTABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

# E-Mail
$IPTABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 995 -j ACCEPT

# Chess
$IPTABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 5799 -j ACCEPT

# IRCD
$IPTABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 6667 -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -m udp -p udp --dport 6667 -j ACCEPT

# Icecast
$IPTABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 8000 -j ACCEPT

################################################################################

$IPTABLES -A INPUT -j REJECT --reject-with icmp-host-prohibited
$IPTABLES -A FORWARD -j REJECT --reject-with icmp-host-prohibited

################################################################################

# IP6TABLES
IP6TABLES=/sbin/ip6tables

$IP6TABLES -F

$IP6TABLES -P INPUT ACCEPT
$IP6TABLES -P OUTPUT ACCEPT
$IP6TABLES -P FORWARD ACCEPT

################################################################################

$IP6TABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IP6TABLES -A INPUT -p ipv6-icmp -m icmp6 --icmpv6-type destination-unreachable -j REJECT --reject-with icmp6-adm-prohibited
$IP6TABLES -A INPUT -i lo -j ACCEPT
$IP6TABLES -A INPUT -p ipv6-icmp -j ACCEPT

################################################################################

# DNS
$IP6TABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT
$IP6TABLES -A INPUT -m state --state NEW -m udp -p udp --dport 53 -j ACCEPT

# FTP
$IP6TABLES -A INPUT -m state --state NEW -p tcp --dport 21 -m state --state NEW -j ACCEPT

# SSH
$IP6TABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

# HTTP
$IP6TABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

# HTTPS
$IP6TABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

# E-Mail
$IP6TABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 995 -j ACCEPT

# Chess
$IP6TABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 5799 -j ACCEPT

# IRCD
$IP6TABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 6667 -j ACCEPT
$IP6TABLES -A INPUT -m state --state NEW -m udp -p udp --dport 6667 -j ACCEPT

# Icecast
$IP6TABLES -A INPUT -m state --state NEW -m tcp -p tcp --dport 8000 -j ACCEPT

################################################################################

$IP6TABLES -A INPUT -j REJECT --reject-with icmp6-adm-prohibited
$IP6TABLES -A FORWARD -j REJECT --reject-with icmp6-adm-prohibited

################################################################################

