我有一个拥有自己的IP和另一个IP(故障转移)的专用服务器谁指的第一个。
我希望改变运行在这个专用服务器上的Proxmox虚拟机(openvz)的网关,以便通过故障转移IP而不是主机主服务器的ip。
一旦连接到虚拟机,当我做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
第一行告诉我主机主服务器的ip。 我希望traceroute显示第二个IP故障转移。
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
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是虚拟机IP(接口venet0)
有任何想法吗 ?
我不太确定,如果我正确理解你,但也许基于源代码的路由是你想要的?
基本上你做了以下几点:
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
你可以select任何数字(或者象征性的名字,如果你通过/etc/iproute2/rt_tables映射它们),而不是保留。
你的configuration可能有点不同,我不知道你的网关,并猜测networking掩码。