Some minor corrections .. Syntax seems to be working OK ..
(Still untested as firewall.)
# Flush, reset firewall
iptables -F
iptables -X
iptables -Z
# Set the policy, the defult last rule
iptables -P INPUT DROP
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# some spoofed packet filtering
# some spoofed souce ip filtering should also be applied
iptables -A INPUT -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
# Lock out some bad guys:
iptables -A INPUT -s 123.123.123.1 -j DROP
iptables -A INPUT -s 123.123.123.2 -j DROP
iptables -A INPUT -s 123.123.123.3 -j DROP
# Some rate and burst control, preventing dos attacks:
iptables -A INPUT -m limit --limit 3/second --limit-burst 5 -j DROP
# To open for answer to ping requests, if wanted:
iptables -A INPUT -p icmp -j ACCEPT
# Open ports on router pc for server/services
iptables -A INPUT -i lo -j ACCEPT
# Open port 20 for all souce ip's
iptables -A INPUT -p tcp --dport 20 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
# Open port 22 for only souce ip 123.123.123.9
iptables -A INPUT -p tcp -s 123.123.123.9 --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 25 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 110 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
#Just an excample for opening a small whole for som udp protocol
iptables -A INPUT -i eth0 -p udp --dport 53 -j ACCEPT
# Dynamic opening / stateful inspection for input chain.
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
To check the statur for the firewall: "iptables -L"
Just some ideas (that hopefully can be used) during one night ...
Ref to this tread:
http://forums.contribs.org/index.php?topic=33097.0