I am trying to forward traffic from one server to another, while keeping the origin requestor IP. Therefor I cannot use SNAT or MASQUERADE.
Public IP: 18.104.22.168
Private IP: 10.0.0.1
Public IP: 22.214.171.124
Private IP: 10.0.0.2
I want to forward traffic från Server A (126.96.36.199) to Server B (10.0.0.2).
This works fine:
iptables -t nat -A PREROUTING -d 188.8.131.52 -p tcp --dport 80 -j DNAT --to-destination 10.0.0.2:80 iptables -t nat -A POSTROUTING -j MASQUERADE
However, because I am using MASQUERADE in this case, the destination server (10.0.0.2) sees all traffic as it would be comming from 184.108.40.206, i.e apache-logs and others are showing all requests as they are comming from 220.127.116.11
How can I setup this instead, so that the origin source IP-address is kept, like a home-router is doing it when using port forwarding.
I assume I need to setup a "route" somehow, so that the outgoing traffic from 10.0.0.2 goes out through Server A and not trying to respond on Server B's public IP?