I have an Ethernet card on CentOS server. It has been configured:
eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 40:f2:e9:9b:b7:bb brd ff:ff:ff:ff:ff:ff
inet 192.168.1.1/24 brd 10.54.19.255 scope global eth1
inet 192.168.1.2/24 scope global secondary eth1
inet6 fe80::42f2:e9ff:fe9b:b7bb/64 scope link
192.168.1.2 is a VIP (virtual IP is created by keepalived).
I want to pass all traffic through virtual IP (192.168.1.2) and the out packets have to be included VIP not real IP (192.168.1.1). And I used iptables but it's not working: the out packets still include real IP not VIP. Here is command for iptables:
iptables -t nat -I POSTROUTING -d x.x.x.x -j SNAT --to 192.168.1.2