Need help with iptables
I need help with IP forwarding with IP tables. I want to preserve the source IP of any connections and route it through Linode via IPTABLES to my own servers. How can I go about doing this? I tried doing a limited masquerade setup and tried a SNAT setup, but neither has properly worked for me.
I found the following resources from others who have attempted to configure IP forwarding using iptables:
- Stack Exchange - iptables - how to keep source IP after forwarding?
- Server Fault - Forward port and keep source IP
From the above resources I get the sense that using SNAT rewrites the Source IP address in the IP header of the packet, which may be necessary in order to establish a TCP connection but may also make it impossible to maintain the original source IP address. You can read more here:
- Develop PAPER - Detailed explanation of DNAT and SNAT settings in iptables under Linux
- Linuxtopia - Linux Packet Filtering and iptables 11.17. SNAT target
You may have more success with what you are trying to achieve using a different service like HAProxy: