---
title: "Configuring a second public floating IP address on a cloud server"
sidebar_label: "Configuring a second public floating IP address on a cloud server"
sidebar_position: 12
description: "How to configure a second public floating IP address on a cloud server"
---

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import {TabItemLabel} from '@selectel/docux/components'
import CreatePublicFloatingIp from '@site/i18n/en/docusaurus-plugin-content-docs/current/_partials/cloud-servers/cloud-networks/create-public-floating-ip.mdx'
import Formbricks from '@theme/MDXComponents/Formbricks'

# Configuring a second public floating IP address on a cloud server

## Setup goal \{#purpose}

Configure a second public floating IP address on a cloud server to access the server using two public IP addresses.

## Requirements \{#what-is-required}

For this setup, we used a [cloud server](/cloud-servers/create/) created from a [pre-built image](/cloud-servers/images/about-images.mdx#default-images) of Ubuntu 24.04 LTS 64-bit.

The server is located in a [private subnet](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx) `192.168.0.0/24` with a default gateway `192.168.0.1`. The private IP address of the cloud server is `192.168.0.2`.

The private subnet of the server is connected to a [cloud router](/cloud-servers/cloud-networks/cloud-routers.mdx) with internet access. The private IP address of the cloud router matches the gateway of the private subnet.

One [public floating IP address](/cloud-servers/cloud-networks/public-floating-ip-addresses.mdx) `203.0.113.10`.

## Result \{#result}

A second port has been added to the cloud server in the private subnet `192.168.0.0/24` with the IP address `192.168.0.3`. To this port, a second public floating IP address `198.51.100.13` is connected. The server receives incoming traffic on both public floating IP addresses — the first one, `203.0.113.10`, and the second one, `198.51.100.13`.

## Configuration steps \{#customization-steps}

1. [Add a port to the private subnet](#add-port-to-subnet).
2. [Create a public floating IP address](#create-public-floating-ip).
3. [Connect the public floating IP address to the port in the private subnet](#assign-ip-to-port-in-private-subnet).
4. [Edit the network configuration file of the cloud server](#edit-cloud-server-network-configuration-file).
5. Optional: [check internet access from and to the internet](#check-internet-access).

## 1. Add a port to the private subnet \{#add-port-to-subnet}

<Tabs queryString="add-port-to-private-subnet">
  <TabItem value="panel" default>
    <TabItemLabel>
      Control panel
    </TabItemLabel>

    1. In the [Control panel](https://my.selectel.ru/vpc/default/networks/), click **Products** in the top menu and select **Cloud Servers**.
    2. Go to the **Network** section → **Private networks** tab.
    3. Open the network page → **Ports** tab.
    4. Click **Add port**.
    5. Select a subnet, for example — `192.168.0.0/24`.
    6. Enter the new private IP address of the port, for example — `192.168.0.3`.
    7. Select the cloud server to which you want to add the port.
    8. Click **Add**.
  </TabItem>

  <TabItem value="openstack">
    <TabItemLabel>
      OpenStack CLI
    </TabItemLabel>

    1. Open [OpenStack CLI](/cloud-servers/tools/openstack-cli/).
    2. Create a port in the subnet:

       ```bash
       openstack port create \
         --network <network> \
         --fixed-ip subnet=<subnet>,ip-address=<port_ip_address> \
         <port_name>
       ```

       Specify:

       * `<network>` — the ID or name of the private network, which can be viewed using the `openstack network list` command;
       * `<subnet>` — the ID or name of the subnet, which can be viewed using the `openstack subnet list` command;
       * `<port_ip_address>` — the new private IP address of the port, for example — `192.168.0.3`;
       * `<port_name>` — the name of the port.
  </TabItem>
</Tabs>

## 2. Create a public floating IP address \{#create-public-floating-ip}

Create one public floating IP address in the same location as the cloud server.

<CreatePublicFloatingIp />

## 3. Connect the public floating IP address to the port in the private subnet \{#assign-ip-to-port-in-private-subnet}

<Tabs queryString="assign-ip-to-port-in-private-subnet">
  <TabItem value="panel" default>
    <TabItemLabel>
      Control panel
    </TabItemLabel>

    1. In the [Control panel](https://my.selectel.ru/vpc/default/networks/), click **Products** in the top menu and select **Cloud Servers**.
    2. Go to the **Network** section → **Private networks** tab.
    3. Open the network page → **Ports** tab.
    4. In the cloud server port card, click **Public IP**.
    5. Select the public floating IP address you [created in step 2](#create-public-floating-ip), for example — `198.51.100.13`.
    6. Click **Connect**.
  </TabItem>

  <TabItem value="openstack">
    <TabItemLabel>
      OpenStack CLI
    </TabItemLabel>

    1. Open [OpenStack CLI](/cloud-servers/tools/openstack-cli/).
    2. Connect the public floating IP address to the port:

       ```bash
       openstack floating ip set --port <port> <floating_ip_address>
       ```

       Specify:

       * `<port>` — the ID of the cloud server port, which can be viewed using the `openstack port list` command;
       * `<floating_ip_address>` — the ID or public floating IP address you [created in step 2](#create-public-floating-ip), for example — `198.51.100.13`. It can be viewed using the `openstack floating ip list` command.
  </TabItem>
</Tabs>

## 4. Edit the network configuration file of the cloud server \{#edit-cloud-server-network-configuration-file}

For the server to accept traffic on both public floating IP addresses, you must configure a separate routing table for each network interface with routes and routing rules. A route determines the gateway for sending traffic, and a routing rule specifies which table to use when sending traffic from a specific private IP address.

1. [Connect to the server](/cloud-servers/manage/connect-to-server.mdx) using the first public floating IP address, for example — `203.0.113.10`.

2. If the cloud server is created from a cloud-init image, then upon server reboot, cloud-init automatically applies the network settings specified in the [Control panel](https://my.selectel.ru/servers/servers/) on the server page on the **Ports** tab. Any manual changes you have made to the server's network settings will not be saved.

   To prevent network settings from being applied via the Control panel when the server reboots, disable network management via cloud-init:

   ```bash
   echo "network: {config: disabled}" >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
   ```

3. Check the MAC address of the port you [added in step 1](#add-port-to-subnet). To do this, display information about the server network interfaces:

   ```bash
   ip link show
   ```

4. Open the `netplan` configuration file using the `vi` text editor:

   ```bash
   vi /etc/netplan/50-cloud-init.yaml
   ```

5. Change the `netplan` configuration file:

   5.1. At the end of the block containing the data for the first network interface, add the following routes:

   ```bash
   routes:
     - to: 0.0.0.0/0
       via: 192.168.0.1
     - to: 192.168.0.0/24
       table: 102
     - to: 0.0.0.0/0
       via: 192.168.0.1
       table: 102
   routing-policy:
     - from: 192.168.0.2/32
       table: 102
   ```

   Where:

   * `0.0.0.0/0` — the default subnet for sending internet traffic;
   * `192.168.0.1` — the gateway of the cloud server's private subnet;
   * `192.168.0.0/24` — the cloud server subnet with a `/24` mask;
   * `102` — the routing table ID for the first interface, a unique number from 1 to 252;
   * `192.168.0.2/32` — the private IP address of the cloud server with a `/32` mask.

   5.2. After the block with the data for the first network interface, add the second network interface and the routes for it:

   ```bash
   eth1:
     match:
       macaddress: 00:00:5e:00:53:01
     set-name: eth1
     addresses:
       - 192.168.0.3/24
     routes:
       - to: 192.168.0.0/24
         table: 103
       - to: 0.0.0.0/0
         via: 192.168.0.1
         table: 103
     routing-policy:
       - from: 192.168.0.3/32
         table: 103
   ```

   Where:

   * `00:00:5e:00:53:01` — the MAC address of the port you obtained in step 3;
   * `192.168.0.3/24` — the private IP address of the cloud server with a `/24` mask;
   * `192.168.0.0/24` — the cloud server subnet with a `/24` mask;
   * `103` — the routing table ID for the second interface, a unique number from 1 to 252;
   * `0.0.0.0/0` — the default subnet for sending internet traffic;
   * `192.168.0.1` — the gateway of the cloud server's private subnet;
   * `192.168.0.3/32` — the private IP address of the cloud server with a `/32` mask.

   <details>
     <summary>Example of a `netplan` configuration file</summary>

     ```bash
     network:
       version: 2
       renderer: networkd
       ethernets:
         # Первый сетевой интерфейс with приватным IP-адресом 192.168.0.2
         eth0:
           match:
             macaddress: 00:00:5e:00:53:00
           set-name: eth0
           addresses:
             - 192.168.0.2/24
           nameservers:
             addresses:
               - 188.93.16.19
               - 188.93.17.19
           routes:
             # Маршрут по умолчанию
             - to: 0.0.0.0/0
               via: 192.168.0.1
             # Маршруты для таблицы маршрутизации 102
             - to: 192.168.0.0/24
               table: 102
             - to: 0.0.0.0/0
               via: 192.168.0.1
               table: 102
           # Исходящий трафик with 192.168.0.2 идет через таблицу маршрутизации 102
           routing-policy:
             - from: 192.168.0.2/32
               table: 102
         # Второй сетевой интерфейс with приватным IP-адресом 192.168.0.3
         eth1:
           match:
             macaddress: 00:00:5e:00:53:01
           set-name: eth1
           addresses:
             - 192.168.0.3/24
           # Маршруты для таблицы маршрутизации 103
           routes:
             - to: 192.168.0.0/24
               table: 103
             - to: 0.0.0.0/0
               via: 192.168.0.1
               table: 103
           # Исходящий трафик with 192.168.0.3 идет через таблицу маршрутизации 103
           routing-policy:
             - from: 192.168.0.3/32
               table: 103
     ```
   </details>

6. Check the file syntax:

   ```bash
   sudo netplan try
   ```

7. Apply the settings:

   ```bash
   sudo netplan apply
   ```

## 5. Optional: check internet access \{#check-internet-access}

1. Open the CLI.

2. Check the server's availability via the new public floating IP address:

   ```bash
   ping 198.51.100.13
   ```

   Where `198.51.100.13` is the public floating IP address you [created in step 2](#create-public-floating-ip).

3. [Connect to the server](/cloud-servers/manage/connect-to-server.mdx) using any of the two public floating IP addresses of the server.

4. From the server, check the availability of any public IP address, for example:

   ```bash
   ping 8.8.8.8
   ```

<Formbricks />
