Azure Network DNS Servers
This page shows how to write Terraform and Azure Resource Manager for Network DNS Servers and write them securely.
azurerm_virtual_network_dns_servers (Terraform)
The DNS Servers in Network can be configured in Terraform with the resource name azurerm_virtual_network_dns_servers
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
The following arguments are supported:
virtual_network_id
- (Required) The ID of the Virtual Network that should be linked to the DNS Zone. Changing this forces a new resource to be created.dns_servers
- (Required) List of IP addresses of DNS servers
The following attributes are exported:
id
- The virtual network DNS server ID.
Explanation in Terraform Registry
Manages the DNS servers associated with a virtual network.
NOTE on Virtual Networks and DNS Servers: Terraform currently provides both a standalone virtual network DNS Servers resource, and allows for DNS servers to be defined in-line within the Virtual Network resource. At this time you cannot use a Virtual Network with in-line DNS servers in conjunction with any Virtual Network DNS Servers resources. Doing so will cause a conflict of Virtual Network DNS Servers configurations and will overwrite virtual networks DNS servers.
Tips: Best Practices for The Other Azure Network Resources
In addition to the azurerm_network_security_group, Azure Network has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
azurerm_network_security_group
Ensure to disable RDP port from the Internet
It is better to disable the RDP port from the Internet. RDP access should not be accepted from the Internet (*, 0.0.0.0, /0, internet, any), and consider using the Azure Bastion Service.
azurerm_network_security_rule
Ensure to set a more restrictive CIDR range for ingress from the internet
It is better to set a more restrictive CIDR range not to use very broad subnets. If possible, segments should be divided into smaller subnets.
azurerm_network_watcher_flow_log
Ensure to enable Retention policy for flow logs and set it to enough duration
It is better to enable a retention policy for flow logs. Flow logs show us all network activity in the cloud environment and support us when we face critical incidents.
Microsoft.Network/virtualNetworks (Azure Resource Manager)
The virtualNetworks in Microsoft.Network can be configured in Azure Resource Manager with the resource name Microsoft.Network/virtualNetworks
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-11-01",
"name": "[parameters('virtualNetworks_CoreServicesVnet_name')]",
"location": "westus",
"properties": {
"addressSpace": {
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-11-01",
"name": "[parameters('virtualNetworks_CoreServicesVnet_name')]",
"location": "westus",
"properties": {
"addressSpace": {
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": {
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": {
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"netHubRG": {
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('hubVnetName')]",
"apiVersion": "2019-11-01",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('mgmtSubnetNSG'))]"
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2018-04-01",
"comments": "Deploy hub network",
"location": "westeurope",
"properties": {
"addressSpace": {
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2019-11-01",
"name": "[parameters('virtualNetworks_phc_p_vnet_001_name')]",
"location": "westeurope",
"properties": {
"addressSpace": {
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vnetName": {
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2018-04-01",
"comments": "Deploy hub network",
"location": "westeurope",
"properties": {
"addressSpace": {
Parameters
name
required - stringtype
required - stringapiVersion
required - stringlocation
required - stringResource location.
tags
optional - stringResource tags.
extendedLocation
optionalname
required - stringThe name of the extended location.
type
required - stringThe type of the extended location.
properties
requiredaddressSpace
requiredaddressPrefixes
required - arrayA list of address blocks reserved for this virtual network in CIDR notation.
dhcpOptions
optionaldnsServers
required - arrayThe list of DNS servers IP addresses.
subnets
optional arrayproperties
optionaladdressPrefix
required - stringThe address prefix for the subnet.
addressPrefixes
optional - arrayList of address prefixes for the subnet.
networkSecurityGroup
optionalid
required - stringResource ID.
routeTable
optionalid
required - stringResource ID.
natGateway
optionalid
required - stringResource ID.
serviceEndpoints
optional arrayservice
optional - stringThe type of the endpoint service.
locations
optional - arrayA list of locations.
serviceEndpointPolicies
optional arrayid
required - stringResource ID.
ipAllocations
optional arrayid
required - stringResource ID.
delegations
optional arrayproperties
optionalserviceName
optional - stringThe name of the service to whom the subnet should be delegated (e.g. Microsoft.Sql/servers).
name
required - stringThe name of the resource that is unique within a subnet. This name can be used to access the resource.
privateEndpointNetworkPolicies
optional - stringEnable or Disable apply network policies on private end point in the subnet.
privateLinkServiceNetworkPolicies
optional - stringEnable or Disable apply network policies on private link service in the subnet.
name
required - stringThe name of the resource that is unique within a resource group. This name can be used to access the resource.
virtualNetworkPeerings
optional arrayproperties
optionalallowVirtualNetworkAccess
optional - booleanWhether the VMs in the local virtual network space would be able to access the VMs in remote virtual network space.
allowForwardedTraffic
optional - booleanWhether the forwarded traffic from the VMs in the local virtual network will be allowed/disallowed in remote virtual network.
allowGatewayTransit
optional - booleanIf gateway links can be used in remote virtual networking to link to this virtual network.
useRemoteGateways
optional - booleanIf remote gateways can be used on this virtual network. If the flag is set to true, and allowGatewayTransit on remote peering is also true, virtual network will use gateways of remote virtual network for transit. Only one peering can have this flag set to true. This flag cannot be set if virtual network already has a gateway.
remoteVirtualNetwork
requiredid
required - stringResource ID.
remoteAddressSpace
optionaladdressPrefixes
required - arrayA list of address blocks reserved for this virtual network in CIDR notation.
remoteBgpCommunities
optionalvirtualNetworkCommunity
required - stringThe BGP community associated with the virtual network.
peeringState
optional - stringThe status of the virtual network peering.
name
required - stringThe name of the resource that is unique within a resource group. This name can be used to access the resource.
enableDdosProtection
optional - booleanIndicates if DDoS protection is enabled for all the protected resources in the virtual network. It requires a DDoS protection plan associated with the resource.
enableVmProtection
optional - booleanIndicates if VM protection is enabled for all the subnets in the virtual network.
ddosProtectionPlan
optionalid
required - stringResource ID.
bgpCommunities
optionalvirtualNetworkCommunity
required - stringThe BGP community associated with the virtual network.
ipAllocations
optional arrayid
required - stringResource ID.