Getting started with Cloud DNS
Create DNS zones, add A records for your test VMs, and test domain name resolution.
Getting started
- Log in to the management console
or sign up. If not signed up yet, navigate to the management console and follow the on-screen instructions. - On the Yandex Cloud Billing
page, make sure you have a linked billing account with theACTIVEorTRIAL_ACTIVEstatus. If you do not have a billing account yet, create one. - If you do not have a folder yet, create one. While creating a folder, you can also create a default virtual network with subnets in all availability zones.
- Create a network and subnets for your test VMs.
- Create VMs named
test-vm-1andtest-vm-2in theru-central1-aavailability zone. Make suretest-vm-1has a public IP address. Connect them to subnets within the same network.
Create a private DNS zone
Domain zones will store resource records.
Create a new domain zone:
- In the management console
, select the folder where you want to create your DNS zone. - Navigate to Cloud DNS.
- Click Zones.
- Click Create zone.
- Specify zone settings:
- Zone:
testing. Its name must end with a trailing dot. - Type:
Internal. - Networks: Network hosting your VMs.
- Name:
test-zone.
- Zone:
- Click Create.
Run this command:
yc dns zone create --name test-zone \
--zone testing. \
--private-visibility network-ids=<network_ID>
Where --private-visibility network-ids is the ID of the network with your test VMs.
Add resource records to your private DNS zone
- Click the zone you created.
- Click Create record.
- Configure the record as follows:
- Name:
test-vm-1. - Type:
A. - Data:
test-vm-1internal IP address. - TTL (in seconds):
600.
- Name:
- Click Create.
- Click Create record once again. Configure another record:
- Name:
test-vm-2. - Type:
A. - Data:
test-vm-2internal IP address. - TTL (in seconds):
600.
- Name:
- Click Create.
Run the following commands:
yc dns zone add-records --name test-zone \
--record "test-vm-1 600 A <VM_internal_IP_address>"
Where --record is the record containing the test-vm-1 internal IP address.
yc dns zone add-records --name test-zone \
--record "test-vm-2 600 A <VM_internal_IP_address>"
Where --record is the record containing the test-vm-2 internal IP address.
Test domain name resolution in the private DNS zone
Connect to test-vm-1 over SSH:
ssh <VM_public_IP_address>
On your VM, try accessing test-vm-2 using its domain name:
host test-vm-2.testing.
Make sure the response returns the IP address of the appropriate VM:
host test-vm-2.testing.
test-vm-2.testing has address 10.0.0.9
Create a public DNS zone
If you have a registered domain name, you can create a public domain zone and add a record to it. In this example, we will use example.com as the domain name.
Create a new public domain zone:
- In the management console
, select the folder where you need to create a public domain zone. - Navigate to Cloud DNS.
- Click Zones.
- Click Create zone.
- Specify zone settings:
- Zone:
example.com.. - Type:
Public. - Name:
test-public-zone.
- Zone:
- Click Create.
Run this command:
yc dns zone create --name test-public-zone \
--zone example.com. \
--public-visibility
Add resource records to the public zone
- Click the zone you created.
- Click Create record.
- Specify the record settings:
- Name:
www. - Type:
A. - Data:
test-vm-1public IP address. - TTL (in seconds):
600.
- Name:
- Click Create.
Run this command:
yc dns zone add-records --name test-public-zone \
--record "www 600 A <VM_public_IP_address>"
Where --record is the record containing the test-vm-1 public IP address.
Delegate your domain name by specifying the addresses of the Yandex Cloud ns1.yandexcloud.net. and ns2.yandexcloud.net. name servers at your registrar.
Test domain name resolution in the public DNS zone
Make sure the created record resolves to the VM's public IP address. Run the following command on your computer:
host www.example.com ns1.yandexcloud.net.
Result:
Using domain server:
Name: ns1.yandexcloud.net.
Address: 84.201.185.208#53
Aliases:
www.example.com has address <test-vm-1_public_IP_address>