I have a proxy server with the below iptables settings, which are proxying the TCP between 10.76.61.236 and 216.239.36.55.
root@casterly-rock:/tmp# iptables -t nat -L PREROUTING -v -n --line-numbers
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 4 208 DNAT tcp -- * * 10.76.61.236 10.99.42.75 to:216.239.36.55
root@casterly-rock:/tmp# iptables -t nat -L POSTROUTING -v -n --line-numbers
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 2 104 SNAT tcp -- * * 10.76.61.236 216.239.36.55 to:10.99.42.75
They work indeed: The packets captured by tshark though I am confused about why the inbound packets can route back to 10.76.61.236 even though I only config the outbound path which I means I’ve changed the source IP to 10.99.42.75 when the packets sending to 216.239.36.55 but the inbound packets still can send back to 10.76.61.236!
Now I have a new demand that I want to modify the received packet’s source IP when it leaves the proxy server: The new flow
Note that the new source IP 192.168.1.1 can’t be accessed by 216.239.36.55, so, I still want it to communicate with 10.99.42.75 but change to 192.168.1.1 with some methods before leaving the server.
I tried to implement it via POSTROUTING table, but it doesn’t work: Some trials
Is it possible? How can I achieve it? I appreciate any help you can provide.