Configure DNS on the private network of a dedicated server
You can configure DNS on private networks of dedicated servers. This will allow servers on the private network to be addressed by domain names instead of IP addresses.
The Private DNS service is used for configuration. The service works on the basis of cloud platform networks, communication with the networks of dedicated servers is carried out through a global router.
Private DNS is configured via API, and the IAM token for the project is used to authenticate requests. For a complete list of API methods for working with the service, see Private DNS API.
-
If you do not already have a private network in your cloud platform, create a private network. The network must be in the same project as the dedicated servers for which you want to use private DNS.
-
Add a service user with the role
member. -
For the added service user, get an IAM token for the project.
-
Open the CLI.
-
Make an API request to create a private zone with records:
curl -X POST \
https://<pool>.cloud.api.selcloud.ru/private-dns/v1/zones \
-H "X-Auth-Token: <token>" \
-H "Content-Type: application/json" \
-d '{
"name": "<zone_name>",
"ttl": <ttl>,
"domain": "<domain_name>.",
"records": [
{
"type": "<record_type>",
"domain": "<subdomain>.<zone_domain_name>.",
"ttl": <record_ttl>,
"values": [
<value1>,<value2>
]
}
]
}'Specify:
-
<pool>- pool where the private network of the cloud platform is located, e.g.ru-3; -
<token>- The IAM token for the project you received in step 3; -
<zone_name>- zone name; -
<ttl>- TTL of the zone in seconds, default is 3600/ TTL is the time during which the zone resource record in the DNS server cache is considered up-to-date and does not need to be re-cached; -
<zone_domain_name>- zone domain name, e.g.example; -
optional: add a block
<"records">with information about resource records in the zone. Records can be created and modified at any time after the zone is created. Records are specified in groups by type, for each group specify:<record_type>- record type:A,AAAA,MX,TXT,CNAME;<subdomain>- domain name of the port, e.g.first. Can contain numbers, Latin letters and hyphens;<record_ttl>- TTL of the record in seconds, default is 3600. To have the record inherit the TTL of the zone, specify-1;<value1>,<value2>- record values.
-
-
Run an API request to connect the private network to a DNS resolver:
curl -X POST \
https://<pool>.cloud.api.selcloud.ru/private-dns/v1/services \
-H "X-Auth-Token: $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"network_id": "<network_id>"
}'Specify:
<pool>- pool where the private network of the cloud platform is located, e.g.ru-3;<network_id>- Network ID, can be copied from the control panel: in the top menu, click Products → Cloud Servers → Network → tab Private Networks → in the network card, click .
-
Link your dedicated server network and cloud platform network through a global router.
-
For each of the dedicated servers on the network that you connected to the global router in step 7, specify private DNS servers-the DNS resolver IP addresses from the cloud network:
Ubuntu
Debian
CentOS
Windows
8.1 Connect to the server via SSH or KVM console.
8.2.Open the
netplanutility configuration file with thevitext editor:vi /etc/netplan/50-cloud-init.yamlor
vi /etc/netplan/01-netcfg.yaml8.3.Specify DNS servers for the network interface of the private network you connected to the global router. To do this, in the desired interface block, add a
nameserversblock with the DNS resolver IP addresses. For example: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>as the IP addresses of the DNS resolver. You can view the addresses in the control panel: in the top menu, click Products → Cloud Servers → Network → Private Networks tab → open the Network page → Ports tab → in the port card labeled DNS Resolver, view the IP addresses.8.4.Press ESC.
8.5.Exit the
vitext editor with your changes saved::wq8.6.Apply the configuration:
netplan apply8.7.Optional: restart the server.
8.1 Connect to the server via SSH or KVM console.
8.2.Open the network interfaces configuration file with
vitext editor:vi /etc/network/interfaces.d/50-cloud-init8.3.Specify DNS servers for the network interface of the private network you connected to the global router. To do this, in the desired interface block, add the line
dns-nameserverswith the DNS resolver IP addresses. For example: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>as the IP addresses of the DNS resolver. You can view the addresses in the control panel: in the top menu, click Products → Cloud Servers → Network → Private Networks tab → open the Network page → Ports tab → in the port card labeled DNS Resolver, view the IP addresses.8.4.Press ESC.
8.5.Exit the
vitext editor with your changes saved::wq8.6.Restart the network:
service networking restart8.7.Optional: restart the server.
8.1 Connect to the server via SSH or KVM console.
8.2.Output the information of the network interfaces:
ip address8.3.Create or open the configuration file of the private network interface with the
vitext editor:vi /etc/sysconfig/network-scripts/ifcfg-<eth_name>Specify
<eth_name>is the name of the network interface of the private network.8.4.Specify DNS servers for the network interface of the private network you connected to the global router. To do this, in the desired interface block, add the line
dns-nameserverswith the DNS resolver IP addresses. For example: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>as the IP addresses of the DNS resolver. You can view the addresses in the control panel: in the top menu, click Products → Cloud Servers → Network → Private Networks tab → open the Network page → Ports tab → in the port card labeled DNS Resolver, view the IP addresses.8.5.Press ESC.
8.6.Exit the
vitext editor with your changes saved::wq8.7.Restart the network:
systemctl restart network8.8.Optional: reboot the server.
8.1 Connect to the server via RDP or KVM console.
8.2.Open Windows Settings.
8.3.Open Network & Internet.
8.4.Open the Network and Sharing Center.
8.5.Open the network interface of the private network.
8.6.Click Properties.
8.7.From the list, select Internet Protocol version 4 (TCP/IPv4).
8.8.Click Properties.
8.9.Select Use the following DNS server addresses.
8.10. In the Preferred DNS server and Alternate DNS server fields, enter the IP addresses of the DNS resolver. You can view the addresses in the Control Panel: in the top menu, click Products → Cloud Servers → Network → Private Networks tab → open the Network page → Ports tab → in the port card labeled DNS Resolver, view the IP addresses.
8.11.Press OK.
8.12.Optional: reboot the server.