---
title: "Configure DNS in the private network of a dedicated server"
sidebar_label: "Configure DNS in the private network"
sidebar_position: 9
description: "How to configure DNS in the private network of a dedicated server"
---

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

# Configure DNS in the private network of a dedicated server

You can configure DNS in the private networks of dedicated servers. This allows you to address servers in the private network using domain names instead of IP addresses.

The [Private DNS](/cloud-servers/private-dns/) service is used for configuration. The service runs on cloud platform networks, and connection to dedicated server networks is established via the [global router](/global-router/).

Private DNS configuration is performed via API; an [IAM token for a project](/api/authorization/#iam-token-project-scoped) is used for request authentication. For a full list of API methods for working with the service, see the [Private DNS API](/api/private-dns/).

1. [Configure private DNS in a cloud platform network](#configure-private-dns-for-cloud-network).
2. [Connect the dedicated server network and the cloud platform network via the global router](#connect-networks-via-global-router).
3. [Specify the DNS server IP addresses on dedicated servers](#set-dns-ip-addreses-on-dedicated-servers).

## 1. Configure private DNS in a cloud platform network \{#configure-private-dns-for-cloud-network}

1. If you do not already have a private network in the cloud platform, [create a private network](/cloud-servers/cloud-networks/private-networks-and-subnets.mdx#create-private-network). The network must be in the same project as the dedicated servers for which you want to use private DNS.

2. In the [Control panel](https://my.selectel.ru/vpc/default/private-dns/), on the top menu, click **Products** and select **Cloud Servers**.

3. Go to the **Private DNS** section.

4. On the **DNS Zones** tab, click **Create DNS zone**.

5. Select a pool.

6. Enter the zone domain. The domain can contain digits, Latin letters, and hyphens. The domain cannot be a top-level domain, for example `example`.

7. Optional: enter the TTL in seconds or leave the default value. TTL is the time that zone resource records are considered up-to-date in the NS server cache and do not require re-caching. The zone TTL will be applied to records that do not have their own TTL specified.

8. Select a network to add to the zone.

9. Connect the network to the DNS resolver by checking the network box.

10. Optional: add records to the zone by clicking **Add record** and filling in the fields depending on the required record type. You can [add](/cloud-servers/private-dns/manage-records/add-record.mdx), [edit](/cloud-servers/private-dns/manage-records/edit-record.mdx), and [delete records](/cloud-servers/private-dns/manage-records/delete-record.mdx) at any time after creating the zone.

    <Tabs queryString="add-record">
      <TabItem value="a" default>
        <TabItemLabel>
          A or AAAA
        </TabItemLabel>

        10.1. Select the record type — A or AAAA.

        10.2. Enter the domain name for which the record will be created. The domain of the zone in which you are creating the record will be added to it automatically.

        10.3. Enter the IP addresses to be associated with the domain name: for an A record, IPv4 addresses; for an AAAA record, IPv6 addresses. You can specify a maximum of 100 IP addresses. Enter the addresses separated by a comma or space, or on a new line.

        10.4. Enter the record TTL in seconds. To apply the zone TTL, enter `-1` or click **Use zone TTL**.

        10.5. Click **Add**.

        10.6. To add another record, click **Add record** and repeat steps 10.1–10.5.
      </TabItem>

      <TabItem value="cname">
        <TabItemLabel>
          CNAME
        </TabItemLabel>

        10.1. Select the record type — CNAME.

        10.2. Enter the domain alias — the domain name that should redirect to the target domain. The domain of the zone in which you are creating the record will be added to it automatically.

        10.3. Enter the target domain name to which the alias should redirect. This can be any domain name in FQDN format, with a dot at the end.

        10.4. Enter the record TTL in seconds. To apply the zone TTL, enter `-1` or click **Use zone TTL**.

        10.5. Click **Add**.

        10.6. To add another record, click **Add record** and repeat steps 10.1–10.5.
      </TabItem>

      <TabItem value="mx">
        <TabItemLabel>
          MX
        </TabItemLabel>

        10.1. Select the record type — MX.

        10.2. Enter the domain name for which the record will be created. The domain of the zone in which you are creating the record will be added to it automatically.

        10.3. Enter the priority and mail server name separated by a space, for example `10 mail.example.com`. Priority is a number from 0 to 65535; the lower the number, the higher the priority. The mail server name must be in the zone domain.

        10.4. Optional: to add another mail server, click **+** and enter the priority and server name. You can add a maximum of 100 mail servers.

        10.5. Enter the record TTL in seconds. To apply the zone TTL, enter `-1` or click **Use zone TTL**.

        10.6. Click **Add**.

        10.7. To add another record, click **Add record** and repeat steps 10.1–10.6.
      </TabItem>

      <TabItem value="txt">
        <TabItemLabel>
          TXT
        </TabItemLabel>

        10.1. Select the record type — TXT.

        10.2. Enter the domain name for which the record will be created. The domain of the zone in which you are creating the record will be added to it automatically.

        10.3. Enter the record value — any text up to 255 characters.

        10.4. Optional: to add another value, click **+** and enter the record value. You can add a maximum of 100 values.

        10.5. Enter the record TTL in seconds. To apply the zone TTL, enter `-1` or click **Use zone TTL**.

        10.6. Click **Add**.

        10.7. To add another record, click **Add record** and repeat steps 10.1–10.6.
      </TabItem>
    </Tabs>

11. Click **Create DNS zone**.

## 2. Connect the dedicated server network and the cloud platform network via the global router \{#connect-networks-via-global-router}

Connect the dedicated server network and the cloud platform network via the global router; to do this, use the [Connect products and services via global router](/global-router/create-network/create-global-router-network.mdx) guide.

## 3. Specify the DNS server IP addresses on dedicated servers \{#set-dns-ip-addreses-on-dedicated-servers}

On each dedicated server in the network that you have [connected to the cloud platform network](#connect-networks-via-global-router), you need to specify private DNS servers — IP addresses of the DNS resolver from the cloud network.

<Tabs queryString="set-dns-ip-addreses-on-dedicated-servers">
  <TabItem value="ubuntu" default>
    <TabItemLabel>
      Ubuntu
    </TabItemLabel>

    1. [Connect to the server via SSH](/dedicated/manage/connect-to-server.mdx#connect-via-ssh) or via 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/<netcfg>.yaml
       ```

       Specify `<netcfg>` — the name of the `netplan` utility configuration file, for example `50-cloud-init.yaml` or `01-netcfg.yaml`.

    3. Specify DNS servers for the private network interface that you have [connected to the cloud platform network](#connect-networks-via-global-router). To do this, add the `nameservers` block with the DNS resolver IP addresses in the block for the required interface. For example:

       ```yaml
       id1:
         addresses:
           - 192.168.0.3/24
         routes:
           - to: 172.16.0.0/24
             via: 192.168.0.1
         nameservers:
           addresses: 
             - <dns_server_ip_address_1>
             - <dns_server_ip_address_2>
       ```

       Specify `<dns_server_ip_address_1>` and `<dns_server_ip_address_2>` — the DNS resolver IP addresses. You can copy the DNS resolver IP addresses in the [Control panel](https://my.selectel.ru/vpc/default/networks): in the top menu, click **Products** → **Cloud Servers** → **Private DNS** → **DNS Resolvers** tab → in the network row, in the **DNS resolver** field, click .<CopyIcon />

    4. Press **ESC**.

    5. Exit the `vi` text editor with your changes saved:

       ```bash
       :wq
       ```

    6. Apply the configuration:

       ```bash
       netplan apply
       ```

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

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

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

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

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

    3. Specify the DNS servers for the private network interface that you [connected to the cloud platform network](#connect-networks-via-global-router). To do this, in the block of the required interface, add the `dns-nameservers` line with the DNS resolver IP addresses. For example:

       ```bash
       auto eth0
       iface eth0 inet static
           address 192.168.0.3
           dns-nameservers <dns_server_ip_address_1> <dns_server_ip_address_2>
       ```

       Specify `<dns_server_ip_address_1>` and `<dns_server_ip_address_2>` — the DNS resolver IP addresses. You can copy the DNS resolver IP addresses in the [Control panel](https://my.selectel.ru/vpc/default/networks): in the top menu, click **Products** → **Cloud Servers** → **Private DNS** → **DNS Resolvers** tab → in the network row, in the **DNS resolver** field, click .<CopyIcon />

    4. Press **ESC**.

    5. Exit the `vi` text editor with your changes saved:

       ```bash
       :wq
       ```

    6. Restart the network:

       ```bash
       service networking restart
       ```

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

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

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

    2. Get the name of the private network interface for which you need to specify DNS servers by displaying information about the network interfaces:

       ```bash
       ip address
       ```

    3. Create or open the private 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 private network interface that you obtained in step 2.

    4. Specify the DNS servers for the private network interface that you [connected to the cloud platform network](#connect-networks-via-global-router). To do this, in the block of the required interface, add lines with the DNS resolver IP addresses. For example:

       ```bash
       NAME="eth0"
       ONBOOT=yes
       BOOTPROTO=none
       IPADDR="192.168.0.3"
       DNS1=<dns_server_ip_address_1>
       DNS2=<dns_server_ip_address_2>
       ```

       Specify `<dns_server_ip_address_1>` and `<dns_server_ip_address_2>` — the DNS resolver IP addresses. You can copy the DNS resolver IP addresses in the [Control panel](https://my.selectel.ru/vpc/default/networks): in the top menu, click **Products** → **Cloud Servers** → **Private DNS** → **DNS Resolvers** tab → in the network row, in the **DNS resolver** field, click .<CopyIcon />

    5. Press **ESC**.

    6. Exit the `vi` text editor with your changes saved:

       ```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 via the [KVM console](/dedicated/manage/connect-to-server.mdx#connect-via-kvm-console).

    2. Open **Windows Settings**.

    3. Open **Network & Internet**.

    4. Open **Network and Sharing Center**.

    5. Open the private network interface.

    6. Click **Properties**.

    7. From the list, select **Internet Protocol version 4 (TCP/IPv4)**.

    8. Click **Properties**.

    9. Select **Use the following DNS server addresses**.

    10. In the **Preferred DNS server** and **Alternate DNS server** fields, enter the DNS resolver IP addresses. You can find the addresses in the [Control panel](https://my.selectel.ru/vpc/default/networks): in the top menu, click **Products** → **Cloud Servers** → **Network** → **Private Networks** tab → open the network page → **Ports** tab → in the port card marked **DNS resolver**, view the IP addresses.

    11. Click **OK**.

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

<Formbricks />
