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 ?
I'm not quite sure if I understand you correctly, but maybe source based routing is what you want?
Basically you do the following:
Instead of the table identifier 42 you can pick any number (or symbolic name, if you map them via
/etc/iproute2/rt_tables
), but some are reserved.Your configuration is probably a bit different, I don't know your gateway for example and guessed the netmask.