I have a Linux machine (RHEL 6.7) with 2 IP's configured on a single NIC (eth1). The primary address, and therefore the address that all traffic appears to come from, is 10.0.0.23. The other is 10.0.0.160.
I am looking for a way to use iptables to change the source IP based on the destination address of a packet. Normally the traffic will 'go out on' 10.0.0.23, but say my packet is destined for 10.0.0.1, I want that packet to 'go out on' 10.0.0.160.
The reason for this is firewalls on the network that are out of my control. There are rules in place allowing traffic from 10.0.0.160 to 10.0.0.1, but not from 10.0.0.23 to 10.0.0.1.
I don't want all traffic to originate from 10.0.0.160, only that destined for 10.0.0.1.
I was looking at using the nat table and maybe a prerouting rule, but don't see a way to change the source address. If it would help I could create an alias for eth1 (so there would be eth1 and eth1:0) but would like to see if there's a solution in the current config.
Thanks in advance for any advice.