Oh my god. Yes, I am sorry. I was too tired and forgot to change the code I only copied.
Anyway. The table should be NAT as I said (but did not use in the code :P) and then PREROUTING. The rule applied should be REDIRECT.
Here is a working shell script. Just make it executable and put it into the rc.d-dir or some other place to make it start on boot.
Code:
#!/bin/sh
# flush tables
iptables -F
iptables -Z
# drop on default
iptables -P INPUT DROP
# redirect port 80 to 8080
iptables -t nat -A PREROUTING -p tcp --dport 80 --to-ports 8080 -j REDIRECT
# established connections
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
Maybe you don't want (or need) to set default to drop all packages but I was just assuming now. Anyway, it is much easier to let all the iptables-commands be in one file instead of typing them.
Check out the man for more info. iptables is kinda big and there are several great books on the subject. Unfortenly I can only recommend swedish books. :P
If you want to redirect to another host use the [b]--destination[b] flag.