---
title: "Connect a load balancer"
sidebar_label: "Connect a load balancer"
description: "How to distribute load between servers using a load balancer: unite servers into a private network, order a load balancer, and verify load balancer operation"
sidebar_position: 2
---

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import MoreVerticalIcon from '@selectel/docux/icons/more-vertical'
import {TabItemLabel} from '@selectel/docux/components'
import CreateGlobalRouter from '@site/i18n/en/docusaurus-plugin-content-docs/current/_partials/global-router/create-global-router.mdx'
import ConnectDedicatedNetworkToGlobalRouter from '@site/i18n/en/docusaurus-plugin-content-docs/current/_partials/global-router/connect-dedicated-network-to-global-router.mdx'
import ConnectCloudNetworkToGlobalRouter from '@site/i18n/en/docusaurus-plugin-content-docs/current/_partials/global-router/connect-cloud-network-to-global-router.mdx'
import ConfigureNetworkInterfaceOfPrivateNetwork from '@site/i18n/en/docusaurus-plugin-content-docs/current/_partials/dedicated/configure-network-interface-of-private-network.mdx'
import Formbricks from '@theme/MDXComponents/Formbricks'

# Connect a load balancer

1. [Create a global router](#create-global-router).

2. [Connect networks and subnets to the global router](#connect-networks-and-subnets-to-global-router) for each VLAN and Cloud platform project where the servers for balancing are located.

   &#x20;For [Cloud powered by VMware](/public-cloud/about/about-public-cloud.mdx), networks and subnets can only be added through [technical support](https://my.selectel.ru/tickets/create/).

3. [Assign IP addresses from the subnets to the servers](#assign-ip-addresses-on-servers).

4. [Configure routing to the load balancer subnet](#configure-routing-up-to-load-balancer-subnet).

5. [Order a load balancer](#order-balancer).

6. [Verify load balancer operation](#check-balancer-operation).

## 1. Create a global router \{#create-global-router}

<CreateGlobalRouter />

## 2. Connect networks and subnets to the global router⁠ \{#connect-networks-and-subnets-to-global-router}

:::danger

When creating a network, do not use addresses from the `10.128.0.0/16` subnet on your servers. This subnet hosts load balancers, and using it may cause load balancer malfunctions.

:::

<Tabs queryString="connect-networks-and-subnets-to-global-router">
  <TabItem value="dedicated" default>
    <TabItemLabel>
      Dedicated server
    </TabItemLabel>

    Use for a dedicated or hosted server.

    <ConnectDedicatedNetworkToGlobalRouter />
  </TabItem>

  <TabItem value="cloud-platform">
    <TabItemLabel>
      Cloud platform
    </TabItemLabel>

    Use for a cloud server, Managed Kubernetes cluster nodes, or a Managed Database cluster.

    <ConnectCloudNetworkToGlobalRouter />
  </TabItem>
</Tabs>

## 3. Assign IP addresses to servers \{#assign-ip-addresses-on-servers}

<Tabs queryString="assign-ip-addresses-on-servers">
  <TabItem value="dedicated" default>
    <TabItemLabel>
      Dedicated server
    </TabItemLabel>

    <ConfigureNetworkInterfaceOfPrivateNetwork />
  </TabItem>

  <TabItem value="cloud-platform">
    <TabItemLabel>
      Cloud platform
    </TabItemLabel>

    1. [Add a cloud server or a Managed Kubernetes cluster node](/cloud-servers/cloud-networks/ports.mdx#add-cloud-server-to-subnet-via-port) to the subnet you connected to the global router. If you do not have a server or node yet, create one. When creating, select the subnet you connected to the global router as the subnet.
    2. Apply the changes depending on the **Apply changes** port parameter. You can view the parameter value in the [control panel](https://my.selectel.ru/vpc/default/servers/): in the top menu, click **Products** → **Cloud Servers** → server page → **Ports** tab → **Port configuration** block:

       * **When rebooting the server** — [programmatically reboot the cloud server](/cloud-servers/manage/reboot-server.mdx) or manually make changes to the network configuration file on the server;
       * **Manually in the network configuration file on the server** — manually make changes to the network configuration file on the server.
  </TabItem>

  <TabItem value="wmvare-cloud">
    <TabItemLabel>
      Cloud powered by VMware
    </TabItemLabel>

    1. Open the **Cloud Director** panel.
    2. Go to the **Virtual Machines** tab.
    3. In the block for the required virtual machine, click the **Details** button.
    4. In the **Hardware** block, select the **NICs** block and click the **Edit - New** button.
    5. Select the global router network.
    6. Click the **Save** button.
  </TabItem>
</Tabs>

## 4. Configure routing to the load balancer subnet \{#configure-routing-up-to-load-balancer-subnet}

On each server, you must pre-configure routing to the subnet where we will host the load balancer when the service is connected. By default, we host load balancers in the `10.128.0.0/16` subnet, but you can choose any suitable `/16` subnet.

<Tabs queryString="configure-routing-up-to-load-balancer-subnet">
  {/* only-in selectel */}

  <TabItem value="dedicated-server-and-vmware-cloud" default>
    <TabItemLabel>
      Dedicated server, cloud powered by VMware
    </TabItemLabel>

    {/* only-in servercore */}

    <TabItem value="dedicated-server" default>
      <TabItemLabel>
        Dedicated server
      </TabItemLabel>

      {/* only-in */}

      <Tabs queryString="dedicated-server">
        <TabItem value="ubuntu" default>
          <TabItemLabel>
            Ubuntu
          </TabItemLabel>

          1. [Connect to the server](/dedicated/manage/connect-to-server.mdx).

          2. Open the network configuration file:

             ```
             vi /etc/netplan/01-netcfg.yaml
             ```

          3. At the end of the block containing the data for the required network interface, add the route:

             ```
             routes:
               - to: <ip_address>/<mask>
                 via: <gateway>
             ```

             Specify:

             * `<ip_address>/<mask>` — the load balancer subnet. You can specify the `10.128.0.0/16` subnet, where we host load balancers by default, or any suitable `/16`;
             * `<gateway>` — the IP address from the server subnet that you designated as the gateway to the global router when [connecting networks and subnets](#connect-networks-and-subnets-to-global-router).

          4. Save the file.

          5. Check the settings:

             ```
             sudo netplan try
             ```

          6. Apply the changes:

             ```
             netplan apply
             ```
        </TabItem>

        <TabItem value="debian">
          <TabItemLabel>
            Debian
          </TabItemLabel>

          1. [Connect to the server](/dedicated/manage/connect-to-server.mdx).

          2. Open the network configuration file:

             ```
             vi  /etc/network/interfaces
             ```

          3. At the end of the block with the data of the corresponding network interface, add the required route:

             ```
             up route add -net <ip_address> netmask <mask> gw <gateway>
             down route del -net <ip_address> netmask <mask> gw <gateway>
             ```

             Specify:

             * `<ip_address>` — the load balancer subnet. You can specify the `10.128.0.0/16` subnet, where we host load balancers by default, or any suitable `/16`;
             * `<mask>` — `255.255.0.0`;
             * `<gateway>` — the IP address from the server subnet that you designated as the gateway to the global router when [connecting networks and subnets](#connect-networks-and-subnets-to-global-router).

          4. Save the file.

          5. Restart the network:

             ```
             sudo /etc/init.d/networking restart
             ```
        </TabItem>

        <TabItem value="centos">
          <TabItemLabel>
            CentOS
          </TabItemLabel>

          1. [Connect to the server](/dedicated/manage/connect-to-server.mdx).

          2. Create and fill in a file for configuring static routes:

             ```
             echo "<ip_address>/<mask> via <gateway>" >> /etc/sysconfig/network-scripts/route-<eth_name>
             ```

             Specify:

             * `<ip_address>/<mask>` — the load balancer subnet. You can specify the `10.128.0.0/16` subnet, where we host load balancers by default, or any suitable `/16`;
             * `<gateway>` — the IP address from the server subnet that you designated as the gateway to the global router when [connecting networks and subnets](#connect-networks-and-subnets-to-global-router);
             * `<eth_name>` — the name of the corresponding local network interface.

          3. Restart the network:

             ```
             systemctl restart network
             ```
        </TabItem>

        <TabItem value="windows">
          <TabItemLabel>
            Windows
          </TabItemLabel>

          1. [Connect to the server via RDP](/dedicated/manage/connect-to-server.mdx#connect-via-rdp) or via the [KVM console](/dedicated/manage/connect-to-server.mdx#connect-via-kvm-console).
          2. Add the required routes one by one:

             ```shell
             route -p ADD <ip_address> MASK <mask> <gateway> METRIC <x>
             ```

             Specify:

             * `<ip_address>` — the load balancer subnet. You can specify the `10.128.0.0/16` subnet, where we host load balancers by default, or any suitable `/16`;
             * `<mask>` — `255.255.0.0`;
             * `<gateway>` — the IP address from the server subnet that you designated as the gateway to the global router when [connecting networks and subnets](#connect-networks-and-subnets-to-global-router);
             * `<x>` — a parameter that specifies the priority of the given gateway, 1 being the highest priority.
        </TabItem>
      </Tabs>

      {/* only-in nothing */}
    </TabItem>
  </TabItem>

  <TabItem value="cloud-platform" default>
    <TabItemLabel>
      Cloud platform
    </TabItemLabel>

    To specify static routes for a cloud server, Managed Database cluster, or Managed Kubernetes cluster, you must [configure a static route on the private subnet](/cloud-servers/cloud-networks/static-routes.mdx#configure-static-routing-on-subnet) where the server or cluster resides.

    When configuring the route, specify the destination subnet — the load balancer subnet.
  </TabItem>
</Tabs>

## 5. Order a load balancer \{#order-balancer}

1. If your servers use the HTTPS protocol, [add your TLS(SSL) certificate to the Certificate Manager](/certificates-manager/certificates/user-certificates.mdx#add-user-certificate). You can also [issue a Let's Encrypt® certificate](/certificates-manager/certificates/lets-encrypt.mdx).

2. In the [control panel](https://my.selectel.ru/network/load-balancer/), on the top menu, click **Products** and select **Load Balancer**.

3. Click **Connect a load balancer**.

4. Select a plan according to the required channel bandwidth — 20, 50, 100, or 1000 Mbps. If you need a different channel bandwidth, select **Other** and specify the required value in Mbps.

5. Specify the global router to which you [connected the networks and subnets](#connect-networks-and-subnets-to-global-router) — its name, identifier, or the list of subnets added to the router. Router details can be viewed in the [control panel](https://my.selectel.ru/network/localnetwork/l3_list): in the top menu, click **Products** → **Global router** → router page.

6. Specify the load balancer subnet you entered when [configuring routing](#configure-routing-up-to-load-balancer-subnet) on the servers.

7. Select a balancing algorithm:

   * Round Robin — a round-robin algorithm where requests are passed to each server in turn;
   * Weighted Round Robin — a weighted round-robin algorithm where each server is assigned a weight coefficient corresponding to its performance and power. Servers with a higher coefficient receive more requests;
   * Source IP hash — an algorithm where the preferred server for receiving a request is selected depending on the HTTP header or IP address;
   * Least Connections — an algorithm where the request is sent to the least loaded server.

8. If Sticky Sessions are required, select the **Sticky Sessions** checkbox.

9. Select the target server protocol: TCP, HTTP, HTTPS.

10. If you selected the TCP protocol, specify the parameters for using the protocol — all private IP addresses assigned within the global router networks, specifying the ports.

11. If you selected the HTTP protocol, specify all combinations of URLs accepted from the Internet and the IP addresses to which they should be redirected, specifying the port. For example, `http://domain.com/page — http://X.X.X.X:X`.

12. If you selected the HTTPS protocol, specify:

    * all combinations of URLs accepted from the Internet and the IP addresses to which they should be redirected, specifying the port. For example, `https://domain.com/page — http://X.X.X.X:X`;
    * ID of the certificate added in step 1. You can find the ID in the [Control Panel](https://my.selectel.ru/certificates/): in the top menu, click **Products** → **Certificate Manager** → in the certificate menu, select **Copy UUID**;<MoreVerticalIcon />
    * ID of the [project](/access-control/projects/about-projects.mdx) where the certificate is located.

13. Optional: if you need to provide any additional data, enter it in the **Additional Comment** field. For example, describe the use case in more detail, specify in which [pools](/infrastructure/locations.mdx#pool) the infrastructure is located, and provide administrator contact information for further details.

14. Click **Connect Load Balancer**.

15. We will create and send a [ticket](https://my.selectel.ru/tickets/) to connect the service. Connection takes up to seven business days. When the load balancer is ready, we will send you the secure public IP address in the ticket, to which you should route incoming traffic for balancing.

## 6. Verify load balancer operation \{#check-balancer-operation}

To check that the load balancer is working, send test requests to the IP address you received when [ordering the load balancer](#order-balancer).

<Formbricks />
