Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AfO] Add Private DNS Resolver #324

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions telco/referenceImplementation/afoArm.json
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,20 @@
"Audit",
"No"
]
},
"subnetMaskForDnsResolverInbound": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Provide subnet for DNS Resolver Inbound Endpoint."
}
},
"subnetMaskForDnsResolverOutbound": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Provide subnet for DNS Resolver Outbound Endpoint."
}
}
},
"variables": {
Expand Down Expand Up @@ -1738,6 +1752,12 @@
},
"enableAvnm": {
"value": "[parameters('enableAvnm')]"
},
"subnetMaskForDnsResolverInbound": {
"value": "[parameters('subnetMaskForDnsResolverInbound')]"
},
"subnetMaskForDnsResolverOutbound": {
"value": "[parameters('subnetMaskForDnsResolverOutbound')]"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,20 @@
"ddosPlanResourceId": {
"type": "string",
"defaultValue": ""
},
"subnetMaskForDnsResolverInbound": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Provide subnet for DNS Resolver Inbound Endpoint."
}
},
"subnetMaskForDnsResolverOutbound": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Provide subnet for DNS Resolver Outbound Endpoint."
}
}
},
"variables": {
Expand All @@ -166,6 +180,9 @@
"rgName": "[concat(parameters('topLevelManagementGroupPrefix'), '-vnethub-', parameters('location'))]",
"azFwPolicyName": "[concat(parameters('topLevelManagementGroupPrefix'), '-azfwpolicy-', parameters('location'))]",
"hubName": "[concat(parameters('topLevelManagementGroupPrefix'), '-hub-', parameters('location'))]",
"dnsResolverName": "[concat(parameters('topLevelManagementGroupPrefix'), '-dnsr-', parameters('location'))]",
"dnsResolverInboundEndpointName": "DefaultInboundEndpoint",
"dnsResolverOutboundEndpointName": "DefaultOutboundEndpoint",
"avnmName": "[concat(parameters('topLevelManagementGroupPrefix'), '-vnm-', parameters('location'))]",
"avnmRgName": "[concat(parameters('topLevelManagementGroupPrefix'), '-netmanager-', parameters('location'))]",
"azVpnGwIpName": "[concat(variables('vpngwname'), '-pip')]",
Expand All @@ -178,8 +195,11 @@
"azErGwPipId": "[concat('/subscriptions/', parameters('connectivitySubscriptionId'), '/resourceGroups/', variables('rgName'), '/providers/Microsoft.Network/publicIPAddresses/', variables('azErGwIpName'))]",
"azFwSubnetId": "[concat('/subscriptions/', parameters('connectivitySubscriptionId'), '/resourceGroups/', variables('rgName'),'/providers/Microsoft.Network/virtualNetworks/', variables('hubname'), '/subnets/AzureFirewallSubnet')]",
"azFwPipId": "[concat('/subscriptions/', parameters('connectivitySubscriptionId'), '/resourceGroups/', variables('rgName'), '/providers/Microsoft.Network/publicIPAddresses/', variables('azFwIpName'))]",
"hubId": "[concat('/subscriptions/', parameters('connectivitySubscriptionId'), '/resourceGroups/', variables('rgName'), '/providers/Microsoft.Network/virtualNetworks/', variables('hubName'))]",
"resourceDeploymentName": "[take(concat(deployment().name, '-hubspoke', parameters('location')), 64)]",
"avnmDeploymentName": "[take(concat(deployment().name, '-avnetmanager', parameters('location')), 64)]",
"dnsResolverInboundSubnetId": "[concat('/subscriptions/', parameters('connectivitySubscriptionId'), '/resourceGroups/', variables('rgName'),'/providers/Microsoft.Network/virtualNetworks/', variables('hubname'), '/subnets/', first(variables('dnsResolverInboundSubnet')).name)]",
"dnsResolverOutboundSubnetId": "[concat('/subscriptions/', parameters('connectivitySubscriptionId'), '/resourceGroups/', variables('rgName'),'/providers/Microsoft.Network/virtualNetworks/', variables('hubname'), '/subnets/', first(variables('dnsResolverOutboundSubnet')).name)]",
// Creating variable that later will be used in conjunction with the union() function to cater for conditional subnet creation while ensuring idempotency
"gwSubnet": [
{
Expand All @@ -197,6 +217,22 @@
}
}
],
"dnsResolverInboundSubnet": [
{
"name": "DnsResolverInboundSubnet",
"properties": {
"addressPrefix": "[parameters('subnetMaskForDnsResolverInbound')]"
}
}
],
"dnsResolverOutboundSubnet": [
{
"name": "DnsResolverOutboundSubnet",
"properties": {
"addressPrefix": "[parameters('subnetMaskForDnsResolverOutbound')]"
}
}
],
"ddosProtectionPlanId": {
"id": "[parameters('ddosPlanResourceId')]"
},
Expand Down Expand Up @@ -305,13 +341,21 @@
]
},
"subnets": "[
union(
if(
not(
empty(parameters('subnetMaskForGw'))), variables('gwSubnet'), json('[]')),
if(
not(
empty(parameters('subnetMaskForAzFw'))), variables('fwSubnet'), json('[]')))]",
union(
if(
not(empty(parameters('subnetMaskForGw'))), variables('gwSubnet'), json('[]')
),
if(
not(empty(parameters('subnetMaskForAzFw'))), variables('fwSubnet'), json('[]')
),
if(
not(empty(parameters('subnetMaskForDnsResolverInbound'))), variables('dnsResolverInboundSubnet'), json('[]')
),
if(
not(empty(parameters('subnetMaskForDnsResolverOutbound'))), variables('dnsResolverOutboundSubnet'), json('[]')
)
)
]",
"enableDdosProtection": "[if(equals(parameters('enableDdoS'), 'Yes'), 'true', 'false')]",
"ddosProtectionPlan": "[if(equals(parameters('enableDdoS'), 'Yes'), variables('ddosProtectionPlanId'), json('null'))]"
}
Expand Down Expand Up @@ -496,6 +540,56 @@
],
"firewallPolicy": "[variables('azFirewallPolicyId')]"
}
},
{
"condition": "[not(parameters('enableAzFwDnsProxy'))]",
"apiVersion": "2020-04-01-preview",
"type": "Microsoft.Network/dnsResolvers",
"name": "[variables('dnsResolverName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/virtualNetworks/', variables('hubName'))]"
],
"properties": {
"virtualNetwork": {
"id": "[variables('hubId')]"
}
}
},
{
"condition": "[not(parameters('enableAzFwDnsProxy'))]",
"apiVersion": "2020-04-01-preview",
"type": "Microsoft.Network/dnsResolvers/inboundEndpoints",
"name": "[variables('dnsResolverInboundEndpointName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/dnsResolvers/', variables('dnsResolverName'))]"
],
"properties": {
"ipConfigurations": [
{
"privateIpAllocationMethod": "Static",
"subnet": {
"id": "[variables('dnsResolverInboundSubnetId')]"
}
}
]
}
},
{
"condition": "[not(parameters('enableAzFwDnsProxy'))]",
"apiVersion": "2020-04-01-preview",
"type": "Microsoft.Network/dnsResolvers/outboundEndpoints",
"name": "[variables('dnsResolverOutboundEndpointName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/dnsResolvers/', variables('dnsResolverName'))]"
],
"properties": {
"subnet": {
"id": "[variables('dnsResolverOutboundSubnetId')]"
}
}
}
]
}
Expand Down
68 changes: 68 additions & 0 deletions telco/referenceImplementation/telco-portal.json
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,72 @@
]
}
},
{
"name": "subnetMaskForDnsResolverInbound",
"type": "Microsoft.Common.TextBox",
"label": "Subnet for DNS Resolver (inbound)",
"toolTip": "Provide address prefix in CIDR notation (e.g 10.200.0.0/28)",
"defaultValue": "10.200.0.0/28",
"visible": "[and(equals(steps('esConnectivityGoalState').esAzFw, 'Yes'), not(equals(steps('esConnectivityGoalState').esHub, 'vwan')), not(equals(steps('esConnectivityGoalState').esAzFwDns, 'Yes')))]",
"constraints": {
"required": true,
"validations": [
{
"regex": "^(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:/(2[0-8]))$",
"message": "Invalid CIDR range. The address prefix must be in the range [20,28]."
},
{
"isValid": "[if(greaterOrEquals(last(split(steps('esConnectivityGoalState').esAddressHubHS, '/')), 8), equals(last(take(split(first(split(steps('esConnectivityGoalState').esAddressHubHS, '/')), '.'), 1)), last(take(split(first(split(steps('esConnectivityGoalState').subnetMaskForDnsResolverInbound, '/')), '.'), 1))), true)]",
"message": "CIDR range not within virtual network CIDR range (first octet)."
},
{
"isValid": "[if(greaterOrEquals(last(split(steps('esConnectivityGoalState').esAddressHubHS, '/')), 16), equals(last(take(split(first(split(steps('esConnectivityGoalState').esAddressHubHS, '/')), '.'), 2)), last(take(split(first(split(steps('esConnectivityGoalState').subnetMaskForDnsResolverInbound, '/')), '.'), 2))), true)]",
"message": "CIDR range not within virtual network CIDR range (second octet)."
},
{
"isValid": "[if(greaterOrEquals(last(split(steps('esConnectivityGoalState').esAddressHubHS, '/')), 24), equals(last(take(split(first(split(steps('esConnectivityGoalState').esAddressHubHS, '/')), '.'), 3)), last(take(split(first(split(steps('esConnectivityGoalState').subnetMaskForDnsResolverInbound, '/')), '.'), 3))), true)]",
"message": "CIDR range not within virtual network CIDR range (third octet)."
},
{
"isValid": "[lessOrEquals(last(split(steps('esConnectivityGoalState').esAddressHubHS, '/')), last(split(steps('esConnectivityGoalState').subnetMaskForDnsResolverInbound, '/')))]",
"message": "CIDR range not within virtual network CIDR range (subnet mask)."
}
]
}
},
{
"name": "subnetMaskForDnsResolverInbound",
"type": "Microsoft.Common.TextBox",
"label": "Subnet for DNS Resolver (outbound)",
"toolTip": "Provide address prefix in CIDR notation (e.g 10.200.0.16/28)",
"defaultValue": "10.200.0.16/28",
"visible": "[and(equals(steps('esConnectivityGoalState').esAzFw, 'Yes'), not(equals(steps('esConnectivityGoalState').esHub, 'vwan')), not(equals(steps('esConnectivityGoalState').esAzFwDns, 'Yes')))]",
"constraints": {
"required": true,
"validations": [
{
"regex": "^(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:/(2[0-8]))$",
"message": "Invalid CIDR range. The address prefix must be in the range [20,28]."
},
{
"isValid": "[if(greaterOrEquals(last(split(steps('esConnectivityGoalState').esAddressHubHS, '/')), 8), equals(last(take(split(first(split(steps('esConnectivityGoalState').esAddressHubHS, '/')), '.'), 1)), last(take(split(first(split(steps('esConnectivityGoalState').subnetMaskForDnsResolverInbound, '/')), '.'), 1))), true)]",
"message": "CIDR range not within virtual network CIDR range (first octet)."
},
{
"isValid": "[if(greaterOrEquals(last(split(steps('esConnectivityGoalState').esAddressHubHS, '/')), 16), equals(last(take(split(first(split(steps('esConnectivityGoalState').esAddressHubHS, '/')), '.'), 2)), last(take(split(first(split(steps('esConnectivityGoalState').subnetMaskForDnsResolverInbound, '/')), '.'), 2))), true)]",
"message": "CIDR range not within virtual network CIDR range (second octet)."
},
{
"isValid": "[if(greaterOrEquals(last(split(steps('esConnectivityGoalState').esAddressHubHS, '/')), 24), equals(last(take(split(first(split(steps('esConnectivityGoalState').esAddressHubHS, '/')), '.'), 3)), last(take(split(first(split(steps('esConnectivityGoalState').subnetMaskForDnsResolverInbound, '/')), '.'), 3))), true)]",
"message": "CIDR range not within virtual network CIDR range (third octet)."
},
{
"isValid": "[lessOrEquals(last(split(steps('esConnectivityGoalState').esAddressHubHS, '/')), last(split(steps('esConnectivityGoalState').subnetMaskForDnsResolverInbound, '/')))]",
"message": "CIDR range not within virtual network CIDR range (subnet mask)."
}
]
}
},
{
"name": "nwSecurity",
"type": "Microsoft.Common.Section",
Expand Down Expand Up @@ -2637,6 +2703,8 @@
"parameters": {
"subnetMaskForGw": "[steps('esConnectivityGoalState').esAddressVpnOrEr]",
"subnetMaskForAzFw": "[steps('esConnectivityGoalState').esAddressFw]",
"subnetMaskForDnsResolverInbound": "[steps('esConnectivityGoalState').subnetMaskForDnsResolverInbound]",
"subnetMaskForDnsResolverOutbound": "[steps('esConnectivityGoalState').subnetMaskForDnsResolverInbound]",
"enableErGw": "[steps('esConnectivityGoalState').esErGw]",
"enableVpnGw": "[steps('esConnectivityGoalState').esVpnGw]",
"enableHub": "[steps('esConnectivityGoalState').esHub]",
Expand Down