I'm trying to get a iptables script to work anyone who can spot the error in it, I keep getting "iptables: No chain/target/match by that name"
understand the error but I cant find where it is.

#!/bin/sh

# change eth0 with the NIC that's connected to the internet
ext_ip="`/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`"
LOG_LEVEL="notice"

# flush all the old rules and also delete them
iptables -F
iptables -X

# enable some extra security options
# it's possible that some of these commands may cause errors, if so just comment
# them out, there not that important anyway
#echo 1 > /proc/sys/net/ipv4/ip_forward
#echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
#echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
#echo 1 > /proc/sys/net/ipv4/tcp_syncookies
#echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route
#echo 1 > /proc/sys/net/ipv4/conf/all/log_martians
#echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter
#echo "1024 9999" > /proc/sys/net/ipv4/ip_local_port_range
#for i in /proc/sys/net/ipv4/conf/*; do
# echo 1 > $i/rp_filter
#done

################################ Input rules #######################################
# set up default policy for incomming packets
iptables -P INPUT DROP

# these rules filter packets based on certain TCP flags
iptables -A INPUT -p tcp --tcp-flags ALL FIN,URG,PSH -j LOG --log-level $LOG_LEVEL --log-prefix "ANTI PORTSCAN: "
iptables -A INPUT -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j LOG --log-level $LOG_LEVEL --log-prefix "ANTI PORTSCAN: "
iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP

# allow everything from the loopback network device
iptables -A INPUT -i lo -j ACCEPT

# these are gateways/dns/dhcp servers from my ISP so I allow everything from them
iptables -A INPUT -i eth0 -s 195.54.112.136 -d $ext_ip -j ACCEPT
iptables -A INPUT -i eth0 -s 195.54.112.198 -d $ext_ip -j ACCEPT
iptables -A INPUT -i eth0 -s 213.112.91.129 -d $ext_ip -j ACCEPT

# these are ports that must be denied access to at all time
DENIED_PORTS="0:20 23:50 60:112 114:6660 7000:64000"
for PORT in $DENIED_PORTS; do
iptables -A INPUT -i eth0 -p tcp --dport $PORT -j LOG --log-level $LOG_LEVEL --log-prefix "DENIED PORTS: "
iptables -A INPUT -i eth0 -p udp --dport $PORT -j LOG --log-level $LOG_LEVEL --log-prefix "DENIED PORTS: "
iptables -A INPUT -i eth0 -p tcp --dport $PORT -j DROP
iptables -A INPUT -i eth0 -p udp --dport $PORT -j DROP
done

# these are ports that i allow at all time (usefull for irc dcc'ing, ftp, ssh)
iptables -A INPUT -i eth0 -p tcp -d $ext_ip --dport 22 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp -d $ext_ip --dport 6667 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp -d $ext_ip --dport 113 -j ACCEPT
# DROP packets associated with an "INVALID" connection.
iptables -A INPUT -m state --state INVALID -j LOG --log-level $LOG_LEVEL --log-prefix "INVALID CONNECTION: "
iptables -A INPUT -m state --state INVALID -j DROP

# ACCEPT packets which are related to an established connection.
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

# deny everything that wasn't explicetely allowed by the above rules
iptables -A INPUT -j LOG --log-level $LOG_LEVEL --log-prefix "DEFAULT: "
iptables -A INPUT -j DROP

################################ Output rules #######################################
iptables -P OUTPUT ACCEPT

################################ Forward rules ######################################
iptables -P FORWARD DROP