Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have problem to redirect a port

I have a linux working like gateway this have 2 eth

Gateway:

eth1 <- wan #public ip
eth0 <- lan #192.168.1.1
lo <- loopback
vboxnet 10.10.10.1

VM:

eth0 <- 10.0.2.15
eth1 <- 10.10.10.10
eth2 <- 192.168.1.244 #use the mac address for asig via DHCP
lo <- loopback

in iptables i have the following rule

-A PREROUTING -d public_ip/32 -i eth1 -p tcp -m tcp --dport 80 -j DNAT --to-destination private_ip
-A POSTROUTING -s 192.168.1.244 -j SNAT --to-source public_ip
-A POSTROUTING -o eth1 -j MASQUERADE
-A FORWARD -i eth1 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i eth0 -o eth1 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT

the rule work fine when is a VM in other host different than gateway. the VM has a bridged. now i've moved the VM to the gateway host, have the same setting, same ip, same bridged network, but when i try from outside never get response on the 80 port.

Note: when the VM start ask me which ethX use for bridged show me, i choose eth0

EDIT

making forward port to VM eth1 and useing tcpdump i can see when the traffic from public_ip to 10.10.10.10 but never response

Half baked solution

for now i made the following port forward

VM:80 (10.10.10.10) -> HOST:8080 (10.10.10.1)

and use iptables to NAT *:80 to 10.10.10.1:8080 and works, but you can see is very tricky solution

share|improve this question
Where do you have that bridge? If that Virtual PC is running on your gateway, add here all interfaces and routing table. – week Nov 15 '12 at 23:29

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.