You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/dns/private-dns-getstarted-cli.md
+83-36Lines changed: 83 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ services: dns
5
5
author: asudbring
6
6
ms.service: azure-dns
7
7
ms.topic: quickstart
8
-
ms.date: 11/30/2023
8
+
ms.date: 07/11/2025
9
9
ms.author: allensu
10
10
ms.custom:
11
11
- devx-track-azurecli
@@ -19,7 +19,7 @@ ms.custom:
19
19
20
20
This quickstart walks you through the steps to create your first private DNS zone and record using the Azure CLI.
21
21
22
-
A DNS zone is used to host the DNS records for a particular domain. To start hosting your domain in Azure DNS, you need to create a DNS zone for that domain name. Each DNS record for your domain is then created inside this DNS zone. To publish a private DNS zone to your virtual network, you specify the list of virtual networks that are allowed to resolve records within the zone. These are called *linked* virtual networks. When autoregistration is enabled, Azure DNS also updates the zone records whenever a virtual machine is created, changes its' IP address, or is deleted.
22
+
A DNS zone is used to host the DNS records for a particular domain. To start hosting your domain in Azure DNS, you need to create a DNS zone for that domain name. Each DNS record for your domain is then created inside this DNS zone. To publish a private DNS zone to your virtual network, you specify the list of virtual networks that are allowed to resolve records within the zone. These are called *linked* virtual networks. When autoregistration is enabled, Azure DNS also updates the zone records whenever a virtual machine is created, changes its IP address, or is deleted.
23
23
24
24
:::image type="content" source="media/private-dns-portal/private-dns-quickstart-summary.png" alt-text="Summary diagram of the quickstart setup." border="false" lightbox="media/private-dns-portal/private-dns-quickstart-summary.png":::
25
25
@@ -52,14 +52,25 @@ az network vnet create \
52
52
--subnet-name backendSubnet \
53
53
--subnet-prefixes 10.2.0.0/24
54
54
55
-
az network private-dns zone create -g MyAzureResourceGroup \
56
-
-n private.contoso.com
55
+
az network vnet subnet create \
56
+
--vnet-name myAzureVNet \
57
+
--resource-group MyAzureResourceGroup \
58
+
--name AzureBastionSubnet \
59
+
--address-prefix 10.2.1.0/26
60
+
61
+
az network private-dns zone create \
62
+
--resource-group MyAzureResourceGroup \
63
+
--name private.contoso.com
57
64
58
-
az network private-dns link vnet create -g MyAzureResourceGroup -n MyDNSLink \
59
-
-z private.contoso.com -v myAzureVNet -e true
65
+
az network private-dns link vnet create \
66
+
--resource-group MyAzureResourceGroup \
67
+
--name MyDNSLink \
68
+
--zone-name private.contoso.com \
69
+
--virtual-network myAzureVNet \
70
+
--registration-enabled true
60
71
```
61
72
62
-
If you want to create a zone just for name resolution (no automatic hostname registration), you could use the `-e false` parameter.
73
+
If you want to create a zone just for name resolution (no automatic hostname registration), you could use the `--registration-enabled false` parameter.
63
74
64
75
### List DNS private zones
65
76
@@ -69,7 +80,7 @@ Specifying the resource group lists only those zones within the resource group:
69
80
70
81
```azurecli
71
82
az network private-dns zone list \
72
-
-g MyAzureResourceGroup
83
+
--resource-group MyAzureResourceGroup
73
84
```
74
85
75
86
Omitting the resource group lists all zones in the subscription:
@@ -78,34 +89,63 @@ Omitting the resource group lists all zones in the subscription:
78
89
az network private-dns zone list
79
90
```
80
91
92
+
## Deploy Azure Bastion
93
+
94
+
Azure Bastion uses your browser to connect to VMs in your virtual network over secure shell (SSH) or remote desktop protocol (RDP) by using their private IP addresses. The VMs don't need public IP addresses, client software, or special configuration. For more information about Azure Bastion, see [Azure Bastion](/azure/bastion/bastion-overview).
Create a public IP address for the Azure Bastion host with [az network public-ip create](/cli/azure/network/public-ip).
100
+
101
+
```azurecli
102
+
az network public-ip create \
103
+
--resource-group MyAzureResourceGroup \
104
+
--name public-ip-bastion \
105
+
--location eastus \
106
+
--allocation-method Static \
107
+
--sku Standard
108
+
```
109
+
110
+
Create an Azure Bastion host with [az network bastion create](/cli/azure/network/bastion). Azure Bastion is used to securely connect to the virtual machines without exposing them to the public internet.
111
+
112
+
```azurecli
113
+
az network bastion create \
114
+
--resource-group MyAzureResourceGroup \
115
+
--name bastion \
116
+
--vnet-name myAzureVNet \
117
+
--public-ip-address public-ip-bastion \
118
+
--location eastus \
119
+
--sku Basic \
120
+
--no-wait
121
+
```
122
+
81
123
## Create the test virtual machines
82
124
83
125
Now, create two virtual machines so you can test your private DNS zone:
84
126
85
127
```azurecli
86
128
az vm create \
87
-
-n myVM01 \
88
-
--admin-username AzureAdmin \
89
-
-g MyAzureResourceGroup \
90
-
-l eastus \
91
-
--subnet backendSubnet \
92
-
--vnet-name myAzureVnet \
93
-
--nsg NSG01 \
94
-
--nsg-rule RDP \
95
-
--image win2016datacenter
129
+
--name myVM01 \
130
+
--admin-username AzureAdmin \
131
+
--resource-group MyAzureResourceGroup \
132
+
--location eastus \
133
+
--subnet backendSubnet \
134
+
--vnet-name myAzureVnet \
135
+
--image win2016datacenter \
136
+
--public-ip-address ""
96
137
```
97
138
98
139
```azurecli
99
140
az vm create \
100
-
-n myVM02 \
101
-
--admin-username AzureAdmin \
102
-
-g MyAzureResourceGroup \
103
-
-l eastus \
104
-
--subnet backendSubnet \
105
-
--vnet-name myAzureVnet \
106
-
--nsg NSG01 \
107
-
--nsg-rule RDP \
108
-
--image win2016datacenter
141
+
--name myVM02 \
142
+
--admin-username AzureAdmin \
143
+
--resource-group MyAzureResourceGroup \
144
+
--location eastus \
145
+
--subnet backendSubnet \
146
+
--vnet-name myAzureVnet \
147
+
--image win2016datacenter \
148
+
--public-ip-address ""
109
149
```
110
150
111
151
Creating a virtual machine will take a few minutes to complete.
@@ -118,10 +158,10 @@ To create a DNS record, use the `az network private-dns record-set [record type]
118
158
119
159
```azurecli
120
160
az network private-dns record-set a add-record \
121
-
-g MyAzureResourceGroup \
122
-
-z private.contoso.com \
123
-
-n db \
124
-
-a 10.2.0.4
161
+
--resource-group MyAzureResourceGroup \
162
+
--zone-name private.contoso.com \
163
+
--record-set-name db \
164
+
--ipv4-address 10.2.0.4
125
165
```
126
166
127
167
### View DNS records
@@ -130,8 +170,8 @@ To list the DNS records in your zone, run:
130
170
131
171
```azurecli
132
172
az network private-dns record-set list \
133
-
-g MyAzureResourceGroup \
134
-
-z private.contoso.com
173
+
--resource-group MyAzureResourceGroup \
174
+
--zone-name private.contoso.com
135
175
```
136
176
137
177
## Test the private zone
@@ -142,18 +182,25 @@ Now you can test the name resolution for your **private.contoso.com** private zo
142
182
143
183
You can use the ping command to test name resolution. So, configure the firewall on both virtual machines to allow inbound ICMP packets.
144
184
145
-
1. Connect to myVM01, and open a Windows PowerShell window with administrator privileges.
146
-
2. Run the following command:
185
+
1. In the [Azure portal](https://portal.azure.com), search for and select **Virtual machines**.
186
+
187
+
1. Select **myVM01**.
188
+
189
+
1. In **Overview**, select **Connect** > **Connect via Bastion**.
190
+
191
+
1. Enter the username and password you created when you deployed the virtual machine, then select **Connect**.
192
+
193
+
1. Open a Windows PowerShell window and run the following command:
0 commit comments