Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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.)

share|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

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

share|improve this answer
    
The site lots its domain in 2012. But it is is similar to what is here, and you can still find it via archive.org, or find similar info elsewhere. –  nealmcb Sep 28 '12 at 5:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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