I'm pretty new to iptables. My server has two Ethernet cards (eth0, eth1) and an ADSL router that is in bridge mode connected to the eth0 which created ppp0 when dialed.

I'm trying to forward external port 80 to my local machine (192.168.2.2) connected in eth1.

My Internet sharing is done by:

iptables -t nat -A POSTROUTING -s 192.168.2.0/255.255.255.0 -o ppp0 -j MASQUERADE

(if there is a better way feel free to show me)

I am trying to use:

iptables -A FORWARD -i eth1 -p tcp --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 80 -j DNAT --to-destination 192.168.2.2:80

but I don't know to which Ethernet interface I should be pointing it. Any ideas?

link|improve this question
feedback

2 Answers

up vote 0 down vote accepted

If you are accessing the Internet through ppp0, that's what you should use for -i in both commands. (Check the default route in ip -4 route to be sure.)

link|improve this answer
thank you, i currently use iptables -t nat -A PREROUTING -p tcp -i ppp0 --dport 80 -j DNAT --to-destination 192.168.2.2:80 iptables -A FORWARD -i ppp0 -p tcp --dport 80 -j ACCEPT which works from the outside, but when i type my external ip into browser (on the same network) its still blocked, any way i could get around that ? – Stef Jul 1 '11 at 16:55
feedback

Check out http://www.hackorama.com/network/portfwd.shtml. It has very good and detailed explanation for what you're trying to do.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.