Skip to content

Commit 8c4e751

Browse files
authored
Merge pull request #104713 from asudbring/privdns-rbac
Privdns rbac
2 parents 107dcd3 + 36b2424 commit 8c4e751

File tree

7 files changed

+290
-0
lines changed

7 files changed

+290
-0
lines changed

articles/dns/TOC.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@
113113
href: dns-sdk.md
114114
- name: Custom domains for Azure resources
115115
href: dns-custom-domain.md
116+
- name: Private DNS
117+
items:
118+
- name: Protect private DNS zones and records
119+
href: dns-protect-private-zones-recordsets.md
116120
- name: Troubleshoot
117121
items:
118122
- name: Troubleshooting guide
Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
---
2+
title: Protecting private4 DNS Zones and Records - Azure DNS
3+
description: In this learning path, get started protecting private DNS zones and record sets in Microsoft Azure DNS.
4+
services: dns
5+
author: asudbring
6+
ms.service: dns
7+
ms.topic: article
8+
ms.date: 02/18/2020
9+
ms.author: allensu
10+
---
11+
12+
# How to protect private DNS zones and records
13+
14+
[!INCLUDE [updated-for-az](../../includes/updated-for-az.md)]
15+
16+
Private DNS zones and records are critical resources. Deleting a DNS zone or a single DNS record can result in a service outage. It's important that DNS zones and records are protected against unauthorized or accidental changes.
17+
18+
This article explains how Azure DNS enables you to protect your private DNS zones and records against such changes. We apply two powerful securities features provided by Azure Resource Manager: [role-based access control](../role-based-access-control/overview.md) and [resource locks](../azure-resource-manager/management/lock-resources.md).
19+
20+
## Role-based access control
21+
22+
Azure Role-Based Access Control (RBAC) enables fine-grained access management for Azure users, groups, and resources. With RBAC, you can grant the level of access that users need. For more information about how RBAC helps you manage access, see [What is Role-Based Access Control](../role-based-access-control/overview.md).
23+
24+
### The Private DNS Zone Contributor role
25+
26+
The Private DNS Zone Contributor role is a built-in role for managing private DNS resources. This role applied to a user or group enables them to manage private DNS resources.
27+
28+
The resource group *myPrivateDNS* contains five zones for Contoso Corporation. Granting the DNS administrator Private DNS Zone Contributor permissions to that resource group, enables full control over those DNS zones. It avoids granting unnecessary permissions. The DNS administrator can't create or stop virtual machines.
29+
30+
The simplest way to assign RBAC permissions is [via the Azure portal](../role-based-access-control/role-assignments-portal.md).
31+
32+
Open **Access control (IAM)** for the resource group, select **Add**, then select the **Private DNS Zone Contributor** role. Select the required users or groups to grant permissions.
33+
34+
![Resource group level RBAC via the Azure portal](./media/dns-protect-private-zones-recordsets/rbac1.png)
35+
36+
Permissions can also be [granted using Azure PowerShell](../role-based-access-control/role-assignments-powershell.md):
37+
38+
```azurepowershell-interactive
39+
# Grant 'Private DNS Zone Contributor' permissions to all zones in a resource group
40+
41+
$rsg = "<resource group name>"
42+
$usr = "<user email address>"
43+
$rol = "Private DNS Zone Contributor"
44+
45+
New-AzRoleAssignment -SignInName $usr -RoleDefinitionName $rol -ResourceGroupName $rsg
46+
```
47+
48+
The equivalent command is also [available via the Azure CLI](../role-based-access-control/role-assignments-cli.md):
49+
50+
```azurecli-interactive
51+
# Grant 'Private DNS Zone Contributor' permissions to all zones in a resource group
52+
53+
az role assignment create \
54+
--assignee "<user email address>" \
55+
--role "Private DNS Zone Contributor" \
56+
--resource-group "<resource group name>"
57+
```
58+
59+
### Private Zone level RBAC
60+
61+
Azure RBAC rules can be applied to a subscription, a resource group or to an individual resource. That resource can be an individual DNS zone, or an individual record set.
62+
63+
For example, the resource group *myPrivateDNS* contains the zone *private.contoso.com* and a subzone *customers.private.contoso.com*. CNAME records are created for each customer account. The administrator account used to manage CNAME records is assigned permissions to create records in the *customers.private.contoso.com* zone. The account can manage *customers.private.contoso.com* only.
64+
65+
Zone-level RBAC permissions can be granted via the Azure portal. Open **Access control (IAM)** for the zone, select **Add**, then select the **Private DNS Zone Contributor** role. Select the required users or groups to grant permissions.
66+
67+
![DNS Zone level RBAC via the Azure portal](./media/dns-protect-private-zones-recordsets/rbac2.png)
68+
69+
Permissions can also be [granted using Azure PowerShell](../role-based-access-control/role-assignments-powershell.md):
70+
71+
```azurepowershell-interactive
72+
# Grant 'Private DNS Zone Contributor' permissions to a specific zone
73+
74+
$rsg = "<resource group name>"
75+
$usr = "<user email address>"
76+
$zon = "<zone name>"
77+
$rol = "Private DNS Zone Contributor"
78+
$rsc = "Microsoft.Network/privateDnsZones"
79+
80+
New-AzRoleAssignment -SignInName $usr -RoleDefinitionName $rol -ResourceGroupName $rsg -ResourceName $zon -ResourceType $rsc
81+
```
82+
83+
The equivalent command is also [available via the Azure CLI](../role-based-access-control/role-assignments-cli.md):
84+
85+
```azurecli-interactive
86+
# Grant 'Private DNS Zone Contributor' permissions to a specific zone
87+
88+
az role assignment create \
89+
--assignee <user email address> \
90+
--role "Private DNS Zone Contributor" \
91+
--scope "/subscriptions/<subscription id>/resourceGroups/<resource group name>/providers/Microsoft.Network/privateDnsZones/<zone name>/"
92+
```
93+
94+
### Record set level RBAC
95+
96+
Permissions are applied at the record set level. The user is granted control to entries they need and are unable to make any other changes.
97+
98+
Record-set level RBAC permissions can be configured via the Azure portal, using the **Access Control (IAM)** button in the record set page:
99+
100+
![Record set level RBAC via the Azure portal](./media/dns-protect-private-zones-recordsets/rbac3.png)
101+
102+
![Record set level RBAC via the Azure portal](./media/dns-protect-private-zones-recordsets/rbac4.png)
103+
104+
Record-set level RBAC permissions can also be [granted using Azure PowerShell](../role-based-access-control/role-assignments-powershell.md):
105+
106+
```azurepowershell-interactive
107+
# Grant permissions to a specific record set
108+
109+
$usr = "<user email address>"
110+
$rol = "Private DNS Zone Contributor"
111+
$sco =
112+
"/subscriptions/<subscription id>/resourceGroups/<resource group name>/providers/Microsoft.Network/privateDnsZones/<zone name>/<record type>/<record name>"
113+
114+
New-AzRoleAssignment -SignInName $usr -RoleDefinitionName $rol -Scope $sco
115+
```
116+
117+
The equivalent command is also [available via the Azure CLI](../role-based-access-control/role-assignments-cli.md):
118+
119+
```azurecli-interactive
120+
# Grant permissions to a specific record set
121+
122+
az role assignment create \
123+
--assignee "<user email address>" \
124+
--role "Private DNS Zone Contributor" \
125+
--scope "/subscriptions/<subscription id>/resourceGroups/<resource group name>/providers/Microsoft.Network/privateDnsZones/<zone name>/<record type>/<record name>"
126+
```
127+
128+
### Custom roles
129+
130+
The built-in Private DNS Zone Contributor role enables full control over a DNS resource. It's possible to build your own custom Azure roles to provide finer-grained control.
131+
132+
The account that is used to manage CNAMEs is granted permission to manage CNAME records only. The account is unable to modify records of other types. The account is unable to do zone-level operations such as zone delete.
133+
134+
The following example shows a custom role definition for managing CNAME records only:
135+
136+
```json
137+
{
138+
"Name": "Private DNS CNAME Contributor",
139+
"Id": "",
140+
"IsCustom": true,
141+
"Description": "Can manage DNS CNAME records only.",
142+
"Actions": [
143+
"Microsoft.Network/privateDnsZones/CNAME/*",
144+
"Microsoft.Network/privateDNSZones/read",
145+
"Microsoft.Authorization/*/read",
146+
"Microsoft.Insights/alertRules/*",
147+
"Microsoft.ResourceHealth/availabilityStatuses/read",
148+
"Microsoft.Resources/deployments/*",
149+
"Microsoft.Resources/subscriptions/resourceGroups/read",
150+
"Microsoft.Support/*"
151+
],
152+
"NotActions": [
153+
],
154+
"AssignableScopes": [
155+
"/subscriptions/c276fc76-9cd4-44c9-99a7-4fd71546436e"
156+
]
157+
}
158+
```
159+
160+
The Actions property defines the following DNS-specific permissions:
161+
162+
* `Microsoft.Network/privateDnsZones/CNAME/*` grants full control over CNAME records
163+
* `Microsoft.Network/privateDNSZones/read` grants permission to read DNS private zones, but not to modify them, enabling you to see the zone in which the CNAME is being created.
164+
165+
> [!NOTE]
166+
> Using a custom RBAC role to prevent deleting record sets while still allowing them to be updated is not an effective control. It prevents record sets from being deleted, but it does not prevent them from being modified. Permitted modifications include adding and removing records from the record set, including removing all records to leave an empty record set. This has the same effect as deleting the record set from a DNS resolution viewpoint.
167+
168+
Custom role definitions can't currently be defined via the Azure portal. A custom role based on this role definition can be created using Azure PowerShell:
169+
170+
```azurepowershell-interactive
171+
# Create new role definition based on input file
172+
173+
New-AzRoleDefinition -InputFile <file path>
174+
```
175+
176+
It can also be created via the Azure CLI:
177+
178+
```azurecli-interactive
179+
# Create new role definition based on input file
180+
181+
az role create -inputfile <file path>
182+
```
183+
184+
The role can then be assigned in the same way as built-in roles, as described earlier in this article.
185+
186+
For more information on how to create, manage, and assign custom roles, see [Custom Roles in Azure RBAC](../role-based-access-control/custom-roles.md).
187+
188+
## Resource locks
189+
190+
Azure Resource Manager supports another type of security control, the ability to lock resources. Resource locks are applied to the resource, and are effective across all users and roles. For more information, see [Lock resources with Azure Resource Manager](../azure-resource-manager/management/lock-resources.md).
191+
192+
There are two types of resource lock: **CanNotDelete** and **ReadOnly**. These lock types can be applied either to a Private DNS zone, or to an individual record set. The following sections describe several common scenarios, and how to support them using resource locks.
193+
194+
### Protecting against all changes
195+
196+
To prevent changes being made, apply a ReadOnly lock to the zone. This lock prevents new record sets from being created, and existing record sets from being modified or deleted.
197+
198+
Zone level resource locks can be created via the Azure portal. From the DNS zone page, select **Locks**, then select **+Add**:
199+
200+
![Zone level resource locks via the Azure portal](./media/dns-protect-private-zones-recordsets/locks1.png)
201+
202+
Zone-level resource locks can also be created via [Azure PowerShell](https://docs.microsoft.com/powershell/module/az.resources/new-azresourcelock?view=latest):
203+
204+
```azurepowershell-interactive
205+
# Lock a DNS zone
206+
207+
$lvl = "<lock level>"
208+
$lnm = "<lock name>"
209+
$rsc = "<zone name>"
210+
$rty = "Microsoft.Network/privateDnsZones"
211+
$rsg = "<resource group name>"
212+
213+
New-AzResourceLock -LockLevel $lvl -LockName $lnm -ResourceName $rsc -ResourceType $rty -ResourceGroupName $rsg
214+
```
215+
216+
The equivalent command is also [available via the Azure CLI](https://docs.microsoft.com/cli/azure/lock?view=azure-cli-latest#az-lock-create):
217+
218+
```azurecli-interactive
219+
# Lock a DNS zone
220+
221+
az lock create \
222+
--lock-type "<lock level>" \
223+
--name "<lock name>" \
224+
--resource-name "<zone name>" \
225+
--namespace "Microsoft.Network" \
226+
--resource-type "privateDnsZones" \
227+
--resource-group "<resource group name>"
228+
```
229+
### Protecting individual records
230+
231+
To prevent an existing DNS record set against modification, apply a ReadOnly lock to the record set.
232+
233+
> [!NOTE]
234+
> Applying a CanNotDelete lock to a record set is not an effective control. It prevents the record set from being deleted, but it does not prevent it from being modified. Permitted modifications include adding and removing records from the record set, including removing all records to leave an empty record set. This has the same effect as deleting the record set from a DNS resolution viewpoint.
235+
236+
Record set level resource locks can currently only be configured using Azure PowerShell. They aren't supported in the Azure portal or Azure CLI.
237+
238+
Azure PowerShell
239+
240+
```azurepowershell-interactive
241+
# Lock a DNS record set
242+
243+
$lvl = "<lock level>"
244+
$lnm = "<lock name>"
245+
$rnm = "<zone name>/<record set name>"
246+
$rty = "Microsoft.Network/privateDnsZones"
247+
$rsg = "<resource group name>"
248+
249+
New-AzResourceLock -LockLevel $lvl -LockName $lnm -ResourceName $rnm -ResourceType $rty -ResourceGroupName $rsg
250+
```
251+
### Protecting against zone deletion
252+
253+
When a zone is deleted in Azure DNS, all record sets in the zone are deleted. This operation can't be undone. Accidentally deleting a critical zone has the potential to have a significant business impact. It's important to protect against accidental zone deletion.
254+
255+
Applying a CanNotDelete lock to a zone prevents the zone from being deleted. Locks are inherited by child resources. A lock prevents any record sets in the zone from being deleted. As described in the note above, it's ineffective since records can still be removed from the existing record sets.
256+
257+
As an alternative, apply a CanNotDelete lock to a record set in the zone, such as the SOA record set. The zone isn't deleted without also deleting the record sets. This lock protects against zone deletion, while still allowing record sets within the zone to be modified freely. If an attempt is made to delete the zone, Azure Resource Manager detects this removal. The removal would also delete the SOA record set, Azure Resource Manager blocks the call because the SOA is locked. No record sets are deleted.
258+
259+
The following PowerShell command creates a CanNotDelete lock against the SOA record of the given zone:
260+
261+
```azurepowershell-interactive
262+
# Protect against zone delete with CanNotDelete lock on the record set
263+
264+
$lvl = "CanNotDelete"
265+
$lnm = "<lock name>"
266+
$rnm = "<zone name>/@"
267+
$rty = "Microsoft.Network/privateDnsZones/SOA"
268+
$rsg = "<resource group name>"
269+
270+
New-AzResourceLock -LockLevel $lvl -LockName $lnm -ResourceName $rnm -ResourceType $rty -ResourceGroupName $rsg
271+
```
272+
Another option to prevent accidental zone deletion is by using a custom role. This role ensures the accounts used to manage your zones don't have zone delete permissions.
273+
274+
When you do need to delete a zone, you can enforce a two-step delete:
275+
276+
- First, grant zone delete permissions
277+
- Second, grant permissions to delete the zone.
278+
279+
The custom role works for all zones accessed by those accounts. Accounts with zone delete permissions, such as the subscription owner, can still accidentally delete a zone.
280+
281+
It's possible to use both approaches - resource locks and custom roles - at the same time, as a defense-in-depth approach to DNS zone protection.
282+
283+
## Next steps
284+
285+
* For more information about working with RBAC, see [Get started with access management in the Azure portal](../role-based-access-control/overview.md).
286+
* For more information about working with resource locks, see [Lock resources with Azure Resource Manager](../azure-resource-manager/management/lock-resources.md).
71.6 KB
Loading
165 KB
Loading
152 KB
Loading
59.9 KB
Loading
119 KB
Loading

0 commit comments

Comments
 (0)