Debian sample iptables configuration script

#!/bin/sh

IPT="/sbin/iptables"

# Flush old rules, old custom tables
$IPT --flush
$IPT --delete-chain

# Set default policies for all three default chains
$IPT -P INPUT DROP
$IPT -P FORWARD DROP
$IPT -P OUTPUT ACCEPT

# Enable free use of loopback interfaces
$IPT -A INPUT -i lo -j ACCEPT
$IPT -A OUTPUT -o lo -j ACCEPT

# All TCP sessions should begin with SYN
$IPT -A INPUT -p tcp ! --syn -m state --state NEW -s 0.0.0.0/0 -j DROP

# Accept inbound TCP packets
$IPT -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT


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

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

Iptables Script Generator: http://www.mista.nu/iptables/

Automatically loading iptables rules

nano /etc/network/if-up.d/iptables
# copy script in file
chmod +x /etc/network/if-up.d/iptables

Source: http://rackerhacker.com/2009/11/16/automatically-loading-iptables-on-debianubuntu/

Fast install with autoloading

wget /uploads/iptables -O /etc/network/if-up.d/iptables

chmod +x /etc/network/if-up.d/iptables

/etc/network/if-up.d/iptables