---
title: "Configure a network interface on a server"
sidebar_label: "Configure a network interface on a server"
sidebar_position: 6
description: "How to configure network interfaces on a server to connect to a private or public network"
---

import Formbricks from '@theme/MDXComponents/Formbricks'
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import {TabItemLabel} from '@selectel/docux/components'
import ConfigureNetworkInterfaceOfPrivateNetwork from '@site/i18n/en/docusaurus-plugin-content-docs/current/_partials/dedicated/configure-network-interface-of-private-network.mdx'

# Configure a network interface on a server

To connect a server to a [private](/dedicated/networks/private-networks-and-subnets.mdx) and [public network](/dedicated/networks/public-networks-and-subnets.mdx), configure the network interfaces on the server.

The network interface for a private network will be configured automatically only during [OS auto-installation](/dedicated/manage/autoinstall-os.mdx) of Linux. For Windows OS, you can [configure the private network interface](#configure-network-interface-of-private-network) only manually.

You can view the parameters for configuration in the [control panel](https://my.selectel.ru/servers): in the top menu, click **Products** → **Dedicated Servers** → **Servers** → server page → tab **Network**.

## Configure the public network interface \{#configure-network-interface-of-public-network}

<Tabs queryString="configure-network-interface-of-public-network">
  <TabItem value="ubuntu" default>
    <TabItemLabel>
      Ubuntu
    </TabItemLabel>

    <Tabs queryString="configure-file">
      <TabItem value="ubuntu-20" default>
        <TabItemLabel>
          Ubuntu 20.04 LTS
        </TabItemLabel>

        1. [Connect to the server via SSH](/dedicated/manage/connect-to-server.mdx#connect-via-ssh) or using the [KVM console](/dedicated/manage/connect-to-server.mdx#connect-via-kvm-console).

        2. Open the `netplan` utility configuration file with the `vi` text editor:

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

        3. Add or change the values for the public network interface settings:

           ```bash
           network:
             ethernets:
               <eth_name>:
                 addresses:
                   - <ip_address>/<mask>
                 gateway4: <gateway>
                 nameservers:
                   addresses: [<dns_servers>]
               renderer: networkd
               version: 2
           ```

           Specify:

           * `<eth_name>` — name of the public network interface;
           * `<ip_address>` — public IP address of the server with a subnet mask, for example `203.0.113.2`;
           * `<mask>` — subnet mask, for example `24`;
           * `<dns_servers>` — DNS servers. We recommend using [Selectel recursive DNS servers](/infrastructure/dns/dns-recursive-servers-list.mdx), but you can specify any available DNS servers;
           * `<gateway>` — gateway.

        4. Press **ESC**.

        5. Exit the `vi` text editor saving your changes:

           ```bash
           :wq
           ```

        6. Apply the configuration:

           ```bash
           netplan apply
           ```

        7. Optional: reboot the server.
      </TabItem>

      <TabItem value="ubuntu-22">
        <TabItemLabel>
          Ubuntu 22.04 LTS, 24.04 LTS
        </TabItemLabel>

        1. [Connect to the server via SSH](/dedicated/manage/connect-to-server.mdx#connect-via-ssh) or using the [KVM console](/dedicated/manage/connect-to-server.mdx#connect-via-kvm-console).

        2. Open the `netplan` utility configuration file with the `vi` text editor:

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

        3. Add or change the values for the public network interface settings:

           ```bash
           network:
             version: 2
             renderer: networkd
             ethernets:
               <eth_name>:
                 addresses:
                   - <ip_address>/<mask>
                 nameservers:
                   addresses: [<dns_servers>]
                 routes:
                   - to: default
                     via: <gateway>
                   - to: <destination_subnet>
                     via: <next_hop_ip_address>
           ```

           Specify:

           * `<eth_name>` — name of the public network interface;
           * `<ip_address>` — public IP address of the server with a subnet mask, for example `203.0.113.2`;
           * `<mask>` — subnet mask, for example `24`;
           * `<dns_servers>` — DNS servers. We recommend using [Selectel recursive DNS servers](/infrastructure/dns/dns-recursive-servers-list.mdx), but you can specify any available DNS servers;
           * `<gateway>` — gateway;
           * `<destination_subnet>` — for static routes: CIDR of the destination subnet to which traffic will be directed;
           * `<next_hop_ip_address>` — for static routes: gateway (next-hop) — the 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.

        4. Press **ESC**.

        5. Exit the `vi` text editor saving your changes:

           ```bash
           :wq
           ```

        6. Apply the configuration:

           ```bash
           netplan apply
           ```

        7. Optional: reboot the server.
      </TabItem>
    </Tabs>
  </TabItem>

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

    1. [Connect to the server via SSH](/dedicated/manage/connect-to-server.mdx#connect-via-ssh) or using the [KVM console](/dedicated/manage/connect-to-server.mdx#connect-via-kvm-console).

    2. Open the network interfaces configuration file with the `vi` text editor:

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

    3. Add or change the values for the public network interface settings:

       ```bash
       auto <eth_name>
       iface <eth_name> inet static
         address <ip_address>/<mask>
         dns-nameservers <dns_servers>
         gateway <gateway>
       ```

       Specify:

       * `<eth_name>` — name of the public network interface;
       * `<ip_address>` — public IP address of the server, for example `203.0.113.2`;
       * `<mask>` — subnet mask, for example `24`;
       * `<dns_servers>` — DNS servers.We recommend using [Selectel recursive DNS servers](/infrastructure/dns/dns-recursive-servers-list.mdx), but you can specify any available DNS servers;
       * `<gateway>` — gateway.

    4. Press **ESC**.

    5. Exit the `vi` text editor saving your changes:

       ```bash
       :wq
       ```

    6. Restart the network:

       ```bash
       service networking restart
       ```

    7. Optional: reboot the server.
  </TabItem>

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

    An example of changing network settings in CentOS is in the blog article [Configuring Networking in CentOS 7](https://selectel.ru/blog/setup-network-centos-7/).

    1. [Connect to the server via SSH](/dedicated/manage/connect-to-server.mdx#connect-via-ssh) or using the [KVM console](/dedicated/manage/connect-to-server.mdx#connect-via-kvm-console).

    2. Output information about the network interfaces:

       ```bash
       ip address
       ```

    3. Create or open a public network interface configuration file with the `vi` text editor:

       ```bash
       vi /etc/sysconfig/network-scripts/ifcfg-<eth_name>
       ```

       Specify `<eth_name>` — the name of the network interface you obtained in step 2.

    4. Add or change the values of the network interface settings:

       ```bash
       NAME="<eth_name>"
       ONBOOT=yes
       NETBOOT=yes
       BOOTPROTO=static
       HWADDR="<mac_address>"
       IPADDR="<ip_address>"
       NETMASK="<mask>"
       GATEWAY="<gateway>"
       TYPE=Ethernet
       ```

       Specify:

       * `<eth_name>` — name of the public network interface;
       * `<mac_address>` — MAC address of the network device;
       * `<ip_address>` — IP address, for example `203.0.113.2`;
       * `<mask>` — subnet mask, for example `255.255.255.0`;
       * `<gateway>` — gateway.

    5. Press **ESC**.

    6. Exit the `vi` text editor saving your changes:

       ```bash
       :wq
       ```

    7. Restart the network:

       ```bash
       systemctl restart network
       ```

    8. Optional: reboot the server.
  </TabItem>

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

    1. [Connect to the server via RDP](/dedicated/manage/connect-to-server.mdx#connect-via-rdp) or using the [KVM console](/dedicated/manage/connect-to-server.mdx#connect-via-kvm-console).

    2. Open **Network and Sharing Center**.

    3. Open the public network interface.

    4. Click **Properties**.

    5. From the list, select **IPv4**.

    6. Click **Properties**.

    7. Specify the network interface parameters:

       * **IP-address** — public IP address of the server, for example `203.0.113.2`;
       * **Subnet mask** — subnet mask, for example `255.255.255.0`.

    8. Click **OK**.
  </TabItem>
</Tabs>

## Configure a private network interface \{#configure-network-interface-of-private-network}

<ConfigureNetworkInterfaceOfPrivateNetwork />

<Formbricks />
