I would like to port forward all that enter to 10.32.43.75:80 to 10.48.5.66:80
how can I do this with iptables in 10.32.43.75?
I tried this, but didnt work:
iptables -A PREROUTING -t nat -i ens33 -p tcp –dport -j DNAT –to 10.48.5.66:80
iptables -A FORWARD -p tcp -d 10.48.5.66 –dport 80 -j ACCEPT
Best Answer
The problem in your setup is that packet's source addresses remain the same. An example of the packet flow, where client is 192.168.100.100:
The solution is to add
MASQUERADE
rule, which changes source IP address to10.32.43.75
on port forwarded packets: