Adding a Failover IP Address in a VM

For this Setup the dedicated server will be hosted at OVH and the hyper visor will be running windows server 2016, although the same could be done through some Linux based hyper visor as long as the VM has a bridged adapter with the correct virtual MAC address.
 
Adding a fail over IP address in a VM is a slightly harder process than just adding a Fail over to a Hyper visor, it requires to to have a valid virtual Mac address for that IP address which can be generated by your Host provider, you should keep this handy throughout the setup process.
 

You will also need the Primary IP address of the hyper-visor, this will be used as the gateway for the VM

Assuming you have setup your VM Correctly and have a Virtual Mac Address in place and designated to the VM you will need to follow the below steps to setup the network interface on the VM.
 
Start by typing ip addr show which should give the output of your current network connections along with the assigned MAC ADDRESS with the interface, here is an example of the output from a virtualization system
 
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether fa:16:3e:8e:5b:cf brd ff:ff:ff:ff:ff:ff
    inet x.x.x.x/32 brd x.x.x.x scope global ens3
       valid_lft forever preferred_lft forever
You can see next to link/ether our Mac Address assigned to the network interface, we will also need to note the interface ID so for this example it is eth0
 
You can now navigate to the /etc/network/interfaces file in the VM and start to edit accordingly, below is an example of what the entry for your eth0 interface should look like
 

Below is an example without any actual values for the addressing, copy and pasting this without editing will accomplish nothing!

auto eth0
iface eth0 inet static
	address FailoverIP
	netmask 255.255.255.255
	broadcast FailoverIP
	post-up route add HYPERVISOR_GATEWAY dev eth0
	post-up route add default gw HYPERVISOR_GATEWAY
	post-down route del default gw HYPERVISOR_GATEWAY
	post-down route del HYPERVISOR_GATEWAY dev eth0
	dns-nameservers 8.8.8.8 8.8.4.4

Above you can see with have FailoverIP and HYPERVISOR_GATEWAY both of these must contain values specified to your network environment! 

FailoverIP should be pretty self explanatory, it is the IP address supplied by your Host as it looks on the panel / email sent to you. For this example we are going to use 192.147.4.2.

HYPERVISOR_GATEWAY Is a little different, you are going to want to obtain the primary IP address of your hyper visor for this example we are going to use 158.325.72.2, you are going to need to alter this IP address as we want the gateway for the hyper visor not the hyper visor itself, this can be done by changing the last prefix to 254 for context the whole IP address should now look like 158.325.72.254 this is your final HYPERVISOR_GATEWAY.

If we combine all of this together your final complete interface block should be

auto eth0
iface eth0 inet static
	address 192.147.4.2
	netmask 255.255.255.255
	broadcast 192.147.4.2
	post-up route add 158.325.72.254 dev eth0
	post-up route add default gw 158.325.72.254
	post-down route del default gw 158.325.72.254
	post-down route del 158.325.72.254 dev eth0
	dns-nameservers 8.8.8.8 8.8.4.4

 You should save and exit your interfaces file with the network block of your interface edited.

Once done you should restart your base networking setup using service networking restart 

You are now done!

No Comments

Back to top