2 ip failover(ou plus) sur une VM, une solution qui fonctionne!
... / 2 ip failover(ou plus) su...
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Question

2 ip failover(ou plus) sur une VM, une solution qui fonctionne!

by
LionelJ1
Created on 2017-07-19 09:15:18 (edited on 2024-09-04 13:19:53) in Serveurs dédiés

Bonjour,

voici comment configurer correctement 2 ip failover sur une VM vmware

soit x.x.x.x => l'ip du serveur esxi
soit y.y.y.y => l'ip failover 1
soit z.z.z.z => l'ip failover 2

pour connaitre le nom de ses interfaces reseau : `ip link`

1. créer une table de routage
`echo "2 production" >> /etc/iproute2/rt_tables`
2. configurer le fichier /etc/network/interfaces comme cela


#The primary network interface
auto ens160
iface ens160 inet static
address y.y.y.y
netmask 255.255.255.255
broadcast y.y.y.y
post-up ip route add x.x.x.254 dev ens160
post-up ip route add default via x.x.x.254 dev ens160
pre-down ip route del x.x.x.254 dev ens160
pre-down ip route del default via x.x.x.254 dev ens160
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 213.186.33.99
# The public network interface
auto ens192
iface ens192 inet static
address z.z.z.z
netmask 255.255.255.255
broadcast z.z.z.z
post-up route add -host x.x.x.254 dev ens192
post-up ip route add default via x.x.x.254 dev ens192 table production
post-up ip rule add from z.z.z.z lookup production prio 1000
pre-down route del x.x.x.254 dev ens192
pre-down ip route del x.x.x.254 dev ens192 table production
pre-down ip rule del z.z.z.z lookup production prio 1000


pour ajouter d'autres ipfailover sur la VM, recommencez a l’étape 1 avec un autre nom de route

Ensuite vous pouvez jouer avec l'API ovh pour automatiser un peu la bascule d'une ip vers un autre serveur /ip/{ip}/move#POST. Attention le format du parametre ip est de cette forme x.x.x.x/32 , en python ca passe pas, il faut remplacer /32 par %2F32

Philippe


2 Replies ( Latest reply on 2017-07-19 20:50:16 by
VirtuBox
)

Merci pour cette petite config, toujours bon à prendre :)

Via le manager, il est possible d'associer la même adresse MAC pour plusieurs IPs, ce qui permet de les ajouter directement, sans avoir à créer une interface supplémentaire.

Voilà la configuration réseau d'une de mes VM sur ESXI 6.5 :
```
auto eth0
iface eth0 inet static
address 213.32.XXX.XX
netmask 255.255.255.255
broadcast 213.32.XXX.XX
post-up route add 151.XX.XX.254 dev eth0
post-up route add default gw 151.XX.XX.254
pre-down route del 151.XX.XX.254 dev eth0
pre-down route del default gw 151.XX.XX.254
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 213.186.33.99

iface eth0 inet6 static
address 2001:XXXX:d:2389::XX
netmask 64
post-up /sbin/ip -f inet6 route add 2001:XXXX:d:23ff:ff:ff:ff:ff dev eth0
post-up /sbin/ip -f inet6 route add default via 2001:XXXX:d:23ff:ff:ff:ff:ff
pre-down /sbin/ip -f inet6 route del 2001:XXXX:d:23ff:ff:ff:ff:ff dev eth0
pre-down /sbin/ip -f inet6 route del default via 2001:XXXX:d:23ff:ff:ff:ff:ff


iface eth0:1 inet static
address 46.XXX.209.XX
netmask 255.255.255.255
auto eth0:1
iface eth0:2 inet static
address 137.XX.159.XXX
netmask 255.255.255.255
auto eth0:2
iface eth0:3 inet static
address 178.XX.104.XXX
netmask 255.255.255.255
auto eth0:3
iface eth0:4 inet static
address 178.XX.80.XXX
netmask 255.255.255.255
auto eth0:4
```