Linux – How do i do IP address translation with iptables

iptableslinuxredhat

I need to create a route in iptables which allows to use my second IP address as source(not default one) when i connect to an external FTP server. How do i create that route for iptables? i am not very familiar with Linux/Redhat any help on the commands would be highly appreciated.

Thanks for any direction!

Best Answer

You need to use a source NATing rule like:

$ sudo iptables -t nat -A POSTROUTING -s your_private_ip -d FTP_server_ip -j SNAT --to-source your_public_ip

You can also specify the interface using -i eth0.