Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 ?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I'm not quite sure if I understand you correctly, but maybe source based routing is what you want?

Basically you do the following:

ip rule add from 10.10.101.2 table 42
ip route add 10.10.101.2/24 dev eth0 table 42
ip route add default dev eth0 via $gateway table 42

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.

share|improve this answer
    
you have fully understood my request –  Kevin Campion May 17 '10 at 11:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.