Change OpenVZ route to pass through ip failover
- by Kevin Campion
I have one dedicaced server with its own IP and another IP (failover) who refer to the first.
I will wish to change the gateway of a Proxmox virtual machine (openvz) who runs on this dedicaced server to go through the failover IP rather than the ip of host main server.
Once connected to a virtual machine, when I do a traceroute
VE# traceroute www.google.fr
traceroute to www.google.fr (209.85.229.104), 30 hops max, 60 byte packets
1 MY_SERVER_NAME.ovh.net (xxx.xxx.xxx.xxx FIRST_IP_MAIN_SERVER) 0.021 ms 0.010 ms 0.009 ms
The first line tells me the ip of host main server.
I would like that the traceroute display the second IP failover.
VE# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.0.2.1 * 255.255.255.255 UH 0 0 0 venet0
default 192.0.2.1 0.0.0.0 UG 0 0 0 venet0
With iptables
HOST# iptables -t nat -L
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- anywhere anywhere
MASQUERADE all -- anywhere anywhere
SNAT tcp -- anywhere 10.10.101.2 tcp dpt:www state NEW,RELATED,ESTABLISHED,UNTRACKED to:SECOND_IP_FAILOVER
SNAT all -- 10.10.101.2 anywhere to:SECOND_IP_FAILOVER
10.10.101.2 is the virtual machine IP (interface venet0)
Any ideas ?