Here's my scenario:
I have a VPS that has two IP addresses and is running OpenVPN (IP Address of OpenVPN server: 10.1.2.1). I want to forward all received traffic on ONE address to VPN-client (10.1.2.2).
Here are the two rules I am CURRENTLY using:
iptables -t nat -A PREROUTING -i venet0 -p ALL -d <EXTERNAL IP #1> -j DNAT --to-destination 10.1.2.2 iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
This works. I can forward the request to the VPN-client and consume the services that are hosted by the VPN-client. However, I have another service that needs to know the TRUE IP address of the INCOMING-CLIENT's request. When I do it the above-mentioned way, the VPN-client thinks the incoming-client has an IP address of 10.1.2.1, which is the IP address of the OpenVPN server.
I've tried many solutions, including replacing the MASQUERADE with...
iptables -t nat -A POSTROUING -o tun0 -s 10.1.2.2 -j SNAT --to-source <EXTERNAL IP #1>
but that doesn't work. All requests just hang.
My networking architecture is only using the venet0 and the tun0, which is the OpenVPN tunnel. Suggestions as to how to get the TRUE IP address of the public-client would be greatly appreciated. Thank you.