Ubuntu 11.04 server iptables port forwarding
5,018
Solution 1
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.)
Solution 2
Check out http://www.hackorama.com/network/portfwd.shtml. It has very good and detailed explanation for what you're trying to do.
Related videos on Youtube
Author by
Stef
Updated on September 18, 2022Comments
-
Stef almost 2 years
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?
-
Stef almost 13 yearsthank 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 ?
-
nealmcb over 11 yearsThe 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.