Skip to content

Commit c1b2ec7

Browse files
authored
Merge pull request #312325 from asudbring/tsk556117-sfi-bastion
SFI Bastion update: private-dns-getstarted-cli.md
2 parents e4c92a2 + 1a0d5ef commit c1b2ec7

1 file changed

Lines changed: 83 additions & 36 deletions

File tree

articles/dns/private-dns-getstarted-cli.md

Lines changed: 83 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: dns
55
author: asudbring
66
ms.service: azure-dns
77
ms.topic: quickstart
8-
ms.date: 11/30/2023
8+
ms.date: 07/11/2025
99
ms.author: allensu
1010
ms.custom:
1111
- devx-track-azurecli
@@ -19,7 +19,7 @@ ms.custom:
1919

2020
This quickstart walks you through the steps to create your first private DNS zone and record using the Azure CLI.
2121

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.
2323

2424
:::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":::
2525

@@ -52,14 +52,25 @@ az network vnet create \
5252
--subnet-name backendSubnet \
5353
--subnet-prefixes 10.2.0.0/24
5454
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
5764
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
6071
```
6172

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.
6374

6475
### List DNS private zones
6576

@@ -69,7 +80,7 @@ Specifying the resource group lists only those zones within the resource group:
6980

7081
```azurecli
7182
az network private-dns zone list \
72-
-g MyAzureResourceGroup
83+
--resource-group MyAzureResourceGroup
7384
```
7485

7586
Omitting the resource group lists all zones in the subscription:
@@ -78,34 +89,63 @@ Omitting the resource group lists all zones in the subscription:
7889
az network private-dns zone list
7990
```
8091

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).
95+
96+
> [!NOTE]
97+
> [!INCLUDE [Pricing](~/reusable-content/ce-skilling/azure/includes/bastion-pricing.md)]
98+
99+
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+
81123
## Create the test virtual machines
82124

83125
Now, create two virtual machines so you can test your private DNS zone:
84126

85127
```azurecli
86128
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 ""
96137
```
97138

98139
```azurecli
99140
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 ""
109149
```
110150

111151
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]
118158

119159
```azurecli
120160
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
125165
```
126166

127167
### View DNS records
@@ -130,8 +170,8 @@ To list the DNS records in your zone, run:
130170

131171
```azurecli
132172
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
135175
```
136176

137177
## Test the private zone
@@ -142,18 +182,25 @@ Now you can test the name resolution for your **private.contoso.com** private zo
142182

143183
You can use the ping command to test name resolution. So, configure the firewall on both virtual machines to allow inbound ICMP packets.
144184

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:
147194

148195
```powershell
149196
New-NetFirewallRule –DisplayName "Allow ICMPv4-In" –Protocol ICMPv4
150197
```
151198

152-
Repeat for myVM02.
199+
1. Close the Bastion connection to **myVM01** and repeat the previous steps to connect to **myVM02**.
153200

154201
### Ping the VMs by name
155202

156-
1. From the myVM02 Windows PowerShell command prompt, ping myVM01 using the automatically registered host name:
203+
1. From the **myVM02** Bastion connection, open a Windows PowerShell command prompt and ping myVM01 using the automatically registered host name:
157204

158205
```powershell
159206
ping myVM01.private.contoso.com

0 commit comments

Comments
 (0)