---
title: "Update Network Settings"
sidebar_label: "Update Network Settings"
description: "How to update network settings on a cloud server, Managed Kubernetes cluster, Managed Database cluster and cloud load balancer"
sidebar_position: 5
---

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import {TabItemLabel} from '@selectel/docux/components'
import CopyIcon from '@selectel/docux/icons/copy'
import Formbricks from '@theme/MDXComponents/Formbricks'

# Update network settings on devices in a subnet

If you have changed the network settings ([DNS servers](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx#change-dns-servers-on-private-subnet), [default gateway](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx#change-default-gateway-on-private-subnet), [static routes](/cloud-servers/cloud-networks/static-routes.mdx)) of a private subnet that contains devices, you must update the network settings on all devices in the subnet to apply the changes.

## Update network settings on a cloud server \{#configure-static-routing}

If you first change the network settings of a private subnet ([DNS servers](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx#change-dns-servers-on-private-subnet), [default gateway](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx#change-default-gateway-on-private-subnet), [static routes](/cloud-servers/cloud-networks/static-routes.mdx)) and then create cloud servers in it, all settings on the servers will be configured automatically.

If you first create cloud servers and then change the subnet network settings, to apply the settings:

1. [Check DHCP in the private subnet](#check-dhcp-in-private-network).
2. [Apply new network settings on the cloud server](#set-new-settings-on-cloud-server).
3. [Edit the cloud server network configuration files](#edit-cloud-server-network-configuration-file).

### 1. Check DHCP in the private subnet \{#check-dhcp-in-private-network}

1. In the [control panel](https://my.selectel.ru/vpc/default/networks/), on the top menu, click **Products** and select **Cloud Servers**.
2. Go to the **Network** section → **Private Networks** tab.
3. Open the network page → **Subnets** tab.
4. In the subnet card, open the **Automatic network settings** block.
5. Check whether the **DHCP server** toggle is enabled or disabled.

### 2. Apply new network settings on the cloud server \{#set-new-settings-on-cloud-server}

#### If DHCP is enabled

Apply the new network settings depending on the DHCP client:

* request information from the DHCP server again on the cloud server — new network settings will be added, and the old ones will not be deleted:

  ```bash
  dhclient <interface_name>
  ```

  Specify `<interface_name>` — interface name, for example, `eth0`;

* or disable and then enable the port and request information from the DHCP server on the cloud server — new network settings will be added, and the old ones will be deleted:

  ```bash
  INTERFACE=<interface_name>; ip link set $INTERFACE down && ip link set $INTERFACE up && dhclient $INTERFACE
  ```

  Specify `<interface_name>` — interface name, for example, `eth0`.

#### If DHCP is disabled

If DHCP is disabled in a private subnet, the algorithm for applying new network settings depends on whether the cloud-init or cloudbase-init agent is present in the images the cloud server was created from. Agents are preinstalled in all [pre-built images](/cloud-servers/images/about-images.mdx#default-images) of the cloud platform. Agents must be installed if you have manually uploaded an image to the Selectel image storage following the guide [Prepare an ISO image for use with the cloud platform](/cloud-servers/images/create-custom-image.mdx).

<Tabs queryString="set-new-settings-on-cloud-server-dhcp-off">
  <TabItem value="cloudon" default>
    <TabItemLabel>
      Cloud-init is installed
    </TabItemLabel>

    1. In the [control panel](https://my.selectel.ru/vpc/default/servers/), on the top menu, click **Products** and select **Cloud Servers**.
    2. Open the cloud server page → **Ports** tab.
    3. If the **Port settings** block shows the **On server reboot** parameter, [perform a soft reboot of the server](/cloud-servers/manage/reboot-server.mdx#perform-soft-reboot).
    4. If the **Port settings** block shows the **Manually in the network configuration file** parameter, [edit the network configuration file](#edit-cloud-server-network-configuration-file) of the cloud server.
  </TabItem>

  <TabItem value="cloudoff">
    <TabItemLabel>
      Cloud-init is not installed
    </TabItemLabel>

    [Edit the network configuration file](#edit-cloud-server-network-configuration-file) of the cloud server.
  </TabItem>
</Tabs>

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

You need to edit the cloud server network configuration file if DHCP is disabled in the private subnet and:

* the cloud server was created from an image without the cloud-init or cloudbase-init agent;
* the cloud server was created from an image with the cloud-init or cloudbase-init agent, but the **Port settings** block shows the **Manually in the network configuration file** parameter.

If you later [enable DHCP](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx#enable-dhcp-in-private-subnet) in the private subnet, the network settings specified in the file will stop working — DHCP applies its own settings to all servers.

:::info

This is a guide with examples of changing network settings in the network configuration file: DNS servers, default gateway, static routes. Configuration files and network settings may vary depending on the distribution.

:::

<Tabs queryString="edit-cloud-server-network-configuration-file">
  <TabItem value="linux" default>
    <TabItemLabel>
      Linux
    </TabItemLabel>

    The configuration depends on the utility installed on the cloud server: ifupdown or netplan. In cloud servers created from [pre-built images](/cloud-servers/images/about-images.mdx#default-images) with Ubuntu 18.04, 20.04, or 22.04, the ifupdown utility is used for network configuration by default. You can [switch network configuration from ifupdown to netplan](/cloud-servers/troubleshooting/netplan-configuration.mdx).

    <Tabs queryString="edit-cloud-server-network-configuration-file-linux">
      <TabItem value="ifupdown" default>
        <TabItemLabel>
          ifupdown
        </TabItemLabel>

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

        2. Open the CLI.

        3. If the cloud server was created from an image with cloud-init, network settings will be synchronized, and the previous network settings will be specified after the server reboots. To disable synchronization, turn off network configuration:

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

        4. Open the network configuration file:

           ```bash
           nano /etc/network/interfaces.d/50-cloud-init.cfg
           ```

        5. Change network settings:

           ```bash
           auto lo
           iface lo inet loopback
               dns-nameservers <dns_server_1> <dns_server_2>

           auto <interface_name>
           iface <interface_name> inet static
               address <ip_address>
               mtu 1500
               post-up route add default gw <gateway> || true
               pre-down route del default gw <gateway> || true
               up route add -net <destination_subnet_ip_address> netmask <destination_subnet_netmask> gw <next_hop_ip_address>
           ```

           Specify:

           * `<dns_server_1>`, `<dns_server_2>` — private subnet DNS servers;
           * `<interface_name>` — network interface name;
           * `<ip_address>` — cloud server IP address with the mask of the private subnet it is located in. For example, `192.168.0.5/29`;
           * `<gateway>` — private subnet default gateway;
           * `<destination_subnet_ip_address>` — for static routes: IP address of the destination subnet that traffic will be routed to. For example, `172.16.0.8`;
           * `<destination_subnet_netmask>` — for static routes: destination subnet mask, for example, `29`;
           * `<next_hop_ip_address>` — for static routes: gateway (next-hop) — IP address through which devices in the source subnet will direct traffic to the destination subnet. You can enter any address from the source subnet.
      </TabItem>

      <TabItem value="netplan">
        <TabItemLabel>
          netplan
        </TabItemLabel>

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

        2. Open the CLI.

        3. Open the network configuration file:

           ```bash
           nano /etc/netplan/config.yaml
           ```

        4. Change network settings:

           ```bash
           network:
             version: 2
             renderer: networkd
             ethernets:
               <interface_name>:
                 addresses:
                   - <ip_address>
                 nameservers:
                   addresses: [<dns_server_1>, <dns_server_2>]
                 routes:
                   - to: default
                     via: <gateway>
                   - to: <destination_subnet>
                     via: <next_hop_ip_address>
           ```

           Specify:

           * `<interface_name>` — network interface name;
           * `<ip_address>` — cloud server IP address with the mask of the private subnet it is located in. For example, `192.168.0.5/29`;
           * `<dns_server_1>`, `<dns_server_2>` — private subnet DNS servers;
           * `<gateway>` — private subnet default gateway;
           * `<destination_subnet>` — for static routes: CIDR of the destination subnet that traffic will be routed to. For example, `172.16.0.8/29`;
           * `<next_hop_ip_address>` — for static routes: gateway (next-hop) — IP address through which devices in the source subnet will direct traffic to the destination subnet. You can enter any address from the source subnet.

        5. Check the file syntax:

           ```bash
           sudo netplan try
           ```

        6. Apply settings:

           ```bash
           sudo netplan apply
           ```
      </TabItem>
    </Tabs>
  </TabItem>

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

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

    2. Run PowerShell as administrator.

    3. Find the name of the private network interface for which you need to change network settings. To do this, retrieve information about the network interfaces:

       ```bash
       Get-NetIPConfiguration
       ```

    4. To change the cloud server IP address in the private subnet:

       4.1. Add a new IP address:

       ```bash
       New-NetIPAddress -InterfaceAlias "<eth_name>" -IPAddress <new_ip_address> -PrefixLength <mask>
       ```

       Specify:

       * `<eth_name>` – the network interface name you obtained in step 3;
       * `<new_ip_address>` — new cloud server IP address in the private subnet. For example, `192.168.0.5`;
       * `<mask>` — subnet mask, for example, `29`.

       4.2. Remove the old IP address:

       ```bash
       Remove-NetIPAddress -InterfaceAlias "<eth_name>" -IPAddress <old_ip_address>
       ```

       Specify:

       * `<eth_name>` – the network interface name you obtained in step 3;
       * `<old_ip_address>` — old cloud server IP address in the private subnet. For example, `192.168.0.6`.

    5. To change the cloud server default gateway in the private subnet:

       5.1. Add a new default gateway:

       ```bash
       New-NetRoute -InterfaceAlias "<eth_name>" -DestinationPrefix 0.0.0.0/0 -NextHop <new_gateway>
       ```

       Specify:

       * `<eth_name>` – the network interface name you obtained in step 3;
       * `<new_gateway>` — new private network default gateway. For example, `192.168.0.2`.

       5.2. Remove the old default gateway:

       ```bash
       Remove-NetRoute -InterfaceAlias "<eth_name>" -DestinationPrefix 0.0.0.0/0 -NextHop <old_gateway>
       ```

       Specify:

       * `<eth_name>` – the network interface name you obtained in step 3;
       * `<old_gateway>` — old private network default gateway. For example, `192.168.0.1`.

    6. To change the DNS servers in the private subnet, set new DNS server addresses:

       ```bash
       Set-DnsClientServerAddress -InterfaceAlias "<eth_name>" -ServerAddresses "<dns_server_1>","<dns_server_2>"
       ```

       Specify:

       * `<eth_name>` – the network interface name you obtained in step 3;
       * `<dns_server_1>, <dns_server_2>` — private subnet DNS servers.

    7. To set a static route on a cloud server:

       7.1. Add a static route:

       ```bash
       New-NetRoute -InterfaceAlias "<eth_name>" -DestinationPrefix <destination_subnet> -NextHop <next_hop_ip_address>
       ```

       Specify:

       * `<eth_name>` – the network interface name you obtained in step 3;
       * `<destination_subnet>` — CIDR of the destination subnet that traffic will be routed to. For example, `172.16.0.8/29`;
       * `<next_hop_ip_address>` — gateway (next-hop) — IP address through which devices in the source subnet will direct traffic to the destination subnet. You can enter any address from the source subnet.

       7.2. If you need to add another route, repeat step 7.1.
  </TabItem>
</Tabs>

## Update network settings on a Managed Kubernetes cluster \{#set-new-settings-in-managed-kubernetes-cluster}

If you first change the network settings of a private subnet ([DNS servers](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx#change-dns-servers-on-private-subnet), [default gateway](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx#change-default-gateway-on-private-subnet), [static routes](/cloud-servers/cloud-networks/static-routes.mdx)) and then create Managed Kubernetes cluster nodes in it, all settings on the cluster nodes will be configured automatically.

If you first create Managed Kubernetes cluster nodes and then change the subnet network settings, to apply the settings, sequentially [reinstall the nodes](/managed-kubernetes/node-groups/reinstall-nodes.mdx#reinstall-nodes-manually).

## Update network settings on a Managed Database cluster \{#set-new-settings-in-managed-database-cluster}

If you first change the network settings of a private subnet ([DNS servers](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx#change-dns-servers-on-private-subnet), [default gateway](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx#change-default-gateway-on-private-subnet), [static routes](/cloud-servers/cloud-networks/static-routes.mdx)) and then create a Managed Database cluster in it, all settings on the cluster will be configured automatically.

If you first create a Managed Database cluster and then change the subnet network settings, to apply the settings:

* [create a ticket](https://my.selectel.ru/tickets/create/). Specify:
  * Managed Database cluster ID. You can copy it in the [control panel](https://my.selectel.ru/vpc/default/dbaas/): in the top menu, click **Products** → **Managed Databases** → in the cluster row, click <CopyIcon />;
  * Project ID. You can copy it in the [control panel](https://my.selectel.ru/vpc/default/dbaas/): in the top menu, click **Products** → **Managed Databases** → open the projects menu (the name of the current project) → in the project row, click <CopyIcon />;
  * [pool](/infrastructure/locations.mdx#pool) that contains the subnet;
  * the new network settings that need to be applied;
* or recreate the Managed Database cluster; for example, restore it from a backup. See the [Restore a cluster (PostgreSQL example](/managed-databases/postgresql/backups.mdx#restore-cluster)) subsection for more details.

## Update network settings on a cloud load balancer \{#set-new-settings-on-cloud-load-balancer}

If you first change the network settings of a private subnet ([DNS servers](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx#change-dns-servers-on-private-subnet), [default gateway](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx#change-default-gateway-on-private-subnet), [static routes](/cloud-servers/cloud-networks/static-routes.mdx)) and then create a cloud load balancer in it, all settings on the load balancer will be configured automatically.

If you first create a cloud load balancer and then change the subnet network settings, to apply the settings:

* [recreate the balancer instance](/cloud-servers/load-balancers/manage/failover.mdx). All load balancer settings, target groups, and rules will be preserved;
* or [create a load balancer](/cloud-servers/load-balancers/create-load-balancer.mdx) from scratch.

## Update network settings on File Storage \{#set-new-settings-on-file-storage}

If you first change the network settings of a private subnet ([DNS servers](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx#change-dns-servers-on-private-subnet), [default gateway](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx#change-default-gateway-on-private-subnet), [static routes](/cloud-servers/cloud-networks/static-routes.mdx)) and then create File Storage in it, all settings on the storage will be configured automatically.

If you first create File Storage and then change the subnet network settings, apply the changes.

1. In the [control panel](https://my.selectel.ru/vpc/default/file-storage/), on the top menu, click **Products** and select **File Storage**.
2. Open the File Storage page → **Settings** tab.
3. Click **Update network settings**.

<Formbricks />
