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