IP. Virtual IP (VIP): what it is, how to get it and assign to instance

A virtual IP is an IP address that can be assigned to multiple instances at once or become a second address to the network interface.

What it is used for
How it works
How it is charged
How to get a VIP and assign it to several instances to create a fault-tolerant system
How to get a VIP and assign it as a second address to the network interface

What it is used for

Using VIP you can create a fault-tolerant infrastructure. Assign it to several instances at once and the address will pass from one machine to another: if the main one is not available the address is instantly passed to another and this instance will send responses to requests. If the second machine is not available the address is passed to the third one and so on (you specify the order). As a result, your users will always get a response when requesting the IP because the machines support each other.

You can also assign a VIP as a second address for the network interface.

How it works

Fault-tolerant system. Most of our machines run on Linux kernel-based OS (Ubuntu, CentOS, Fedora, Debian, CoreOS, Fedora-CoreOS, SUSE). For them, a fault-tolerant system can be created using keepalived, a system daemon for Linux that balances the load between servers. If the main instance fails, the daemon passes the VIP to the backup one. It uses VRRP (Virtual Router Redundancy Protocol) to pass the VIP address.

VIP as a second address for the network interface. You reserve a VIP and assign it to an instance, first in the settings of our system, then in the settings of the machine. As a result, the VIP becomes the address of this instance on a par with its regular IP: the machine can receive and transmit data on behalf of both addresses.

How it is charged

VIP is a format of using Reserved IP. Its tariffication does not differ from the tariffication of reserved addresses: the IP price per month is displayed in the order window, you pay only for the time from creating the IP to deleting it. For example, if you had reserved an IP and then deleted it after an hour, you will be charged only for an hour of use. The price doesn’t depend on whether the address is assigned to the instance or not.

1.png

How to get a VIP and assign it to several instances to create a fault-tolerant system

  1. In the "Networks" → "Reserved IPs" section, reserve an address in a public or private network (select the one where you want to create a fault-tolerant system).

2.png3.png4.png

  1. Convert your reserved IP to VIP and assign it to instances inside our system. To do this, click the selector next to the IP and select "VIP settings". In the pop-up window, enable the "Is VIP" slider and assign this address to required instances using the "Add Instance" button.

5.png6.png

  1. Install keepalived on your instances. The up-to-date instruction for installing it for the required operating system you can find on the Internet. Using the same instructions, edit the keepalived configuration file on the machines: set the state "MASTER" for the main instance, and state "BACKUP" for the backup ones. Also, set the “priority” value, it determines the order with which the VIP will be passed between devices. If the master server fails the address will be transferred to the machine with the highest priority value, if the second machine fails the VIP will go to the next priority device, and so on.

  2. Run keepalived on your instances and add it to the autostart list. The fault-tolerant system will start working.

How to get a VIP and assign it as a second address to the network interface

  1. In the "Networks" → "Reserved IPs" section, reserve an address in a public or private network (select the one where you want to add a second address for the network interface).

7.png8.png9.png

  1. Assign your VIP to an instance inside our system. To do this, click the selector next to the IP and select "VIP settings". In the pop-up window, enable the "Is VIP" slider and assign the VIP to the desired machine using the "Add Instance" button.

10.png11.png

  1. Configure VIP in instance settings.

Instructions for instances on any OS except Windows

Connect to the instance. The VIP can be configured on the fly with a simple command (you have to run it as an administrator):

ip addr add [VIP]/[mask] dev [interface name]

The command will instantly assign the VIP to your instance; the binding will remain in effect as long as the equipment is turned on. After rebooting, you can enter the command again and the VIP will again belong to the machine.

In this command:

● VIP is the reserved IP that you use as a VIP.     

12.png

● Mask is a subnet mask, you can view it in the settings of the instance in the "Networking" tab by expanding the line with the interface.     

13.png

● Interface name is the name of the instance’s network interface, you can find it using the command:     

ifconfig

The name will appear at the beginning of the first line.

14.png

For example, if your reserved IP is 45.147.140.22, the subnet mask is 24, and the interface name is enp1s0, then the command is: ip addr add 45.147.140.22/24 dev enp1s0. And to run it, for example, on an Ubuntu system as an administrator you need to add "sudo" at the beginning:

15.png

The VIP will be configured. To check if it works, try connecting to the instance via SSH using your VIP: the connection should be successful. If the connection doesn’t work, most likely you entered the wrong command to assign the IP or forgot to add it to the machine inside our system. Repeat steps №2 and №3.

VIP can also be bound to an instance permanently. To do this, you need to add the address to the network settings within the system. The directory and structure of the configuration file may be different not only in different operating systems but even within releases of the same system. We deliberately do not leave a specific instruction — it may become out of date at any time. To bound the VIP, open the official documentation of the operating system of your machine on the Internet and configure the address according to the instructions from there.

Instructions for instances on Windows OS

  1. Connect to the instance, open a command prompt and enter the command:

ipconfig

You will see the connection parameters. Do not close the command prompt: you will need the values ​​from the IPv4 Address, Subnet Mask and Default Gateway lines for the step №4.

16.png

  1. Open Control Panel → Network and Internet → Network Connections. Right-click the adapter and select Properties.

17.png

  1. Click the line "Internet Protocol Version 4 (TCP/IPv4)" and then click "Properties".

18.png

  1. Copy IP, subnet mask, and default gateway from the command prompt to the corresponding lines. Then click "Advanced ...".

19.png

  1. Click "Add ...". In the pop-up window, enter your VIP (the reserved IP that you previously added to the instance as a VIP) in the "IP address" line, and enter the subnet mask from the command prompt in the "Subnet mask" line. Then click "Add".

20.png21.png

  1. Confirm all changes with the "OK" buttons.

  2. The VIP will be configured. To check if it works, try connecting to the instance using your VIP: the connection should be successful. If the connection fails, most likely you have configured the adapter incorrectly or forgot to assign the VIP to the instance inside our system. Repeat the steps of the instructions again.

 

 

Was this article helpful?
Recently viewed articles