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.

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

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.

risk-label

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.

risk-label

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.

risk-label

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.

Review your Azure Network settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

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

template.json#L21
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2020-11-01",
            "name": "[parameters('virtualNetworks_CoreServicesVnet_name')]",
            "location": "westus",
            "properties": {
                "addressSpace": {
azuredeploy.json#L21
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2020-11-01",
            "name": "[parameters('virtualNetworks_CoreServicesVnet_name')]",
            "location": "westus",
            "properties": {
                "addressSpace": {
network-subnets.json
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "moodleCommon": {
network-subnets.json
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "moodleCommon": {
vNet_Peering_Fed.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "netHubRG": {
HubSpokev4.json#L83
      "type": "Microsoft.Network/virtualNetworks",
      "name": "[variables('hubVnetName')]",
      "apiVersion": "2019-11-01",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[resourceId('Microsoft.Network/networkSecurityGroups', variables('mgmtSubnetNSG'))]"
networks.json#L29
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2018-04-01",
            "comments": "Deploy hub network",
            "location": "westeurope",
            "properties": {
                "addressSpace": {
template.json#L13
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2019-11-01",
            "name": "[parameters('virtualNetworks_phc_p_vnet_001_name')]",
            "location": "westeurope",
            "properties": {
                "addressSpace": {
az.02B.deploy.virtual-network.subnet.json
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "vnetName": {
delete.json#L29
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2018-04-01",
            "comments": "Deploy hub network",
            "location": "westeurope",
            "properties": {
                "addressSpace": {

Parameters

  • name required - string
  • type required - string
  • apiVersion required - string
  • location required - string

    Resource location.

  • tags optional - string

    Resource tags.

  • extendedLocation optional
      • name required - string

        The name of the extended location.

      • type required - string

        The type of the extended location.

  • properties required
      • addressSpace required
          • addressPrefixes required - array

            A list of address blocks reserved for this virtual network in CIDR notation.

      • dhcpOptions optional
          • dnsServers required - array

            The list of DNS servers IP addresses.

      • subnets optional array
          • properties optional
              • addressPrefix required - string

                The address prefix for the subnet.

              • addressPrefixes optional - array

                List of address prefixes for the subnet.

              • networkSecurityGroup optional
                  • id required - string

                    Resource ID.

              • routeTable optional
                  • id required - string

                    Resource ID.

              • natGateway optional
                  • id required - string

                    Resource ID.

              • serviceEndpoints optional array
                  • service optional - string

                    The type of the endpoint service.

                  • locations optional - array

                    A list of locations.

              • serviceEndpointPolicies optional array
                  • id required - string

                    Resource ID.

              • ipAllocations optional array
                  • id required - string

                    Resource ID.

              • delegations optional array
                  • properties optional
                      • serviceName optional - string

                        The name of the service to whom the subnet should be delegated (e.g. Microsoft.Sql/servers).

                  • name required - string

                    The name of the resource that is unique within a subnet. This name can be used to access the resource.

              • privateEndpointNetworkPolicies optional - string

                Enable or Disable apply network policies on private end point in the subnet.

              • privateLinkServiceNetworkPolicies optional - string

                Enable or Disable apply network policies on private link service in the subnet.

          • name required - string

            The name of the resource that is unique within a resource group. This name can be used to access the resource.

      • virtualNetworkPeerings optional array
          • properties optional
              • allowVirtualNetworkAccess optional - boolean

                Whether the VMs in the local virtual network space would be able to access the VMs in remote virtual network space.

              • allowForwardedTraffic optional - boolean

                Whether the forwarded traffic from the VMs in the local virtual network will be allowed/disallowed in remote virtual network.

              • allowGatewayTransit optional - boolean

                If gateway links can be used in remote virtual networking to link to this virtual network.

              • useRemoteGateways optional - boolean

                If 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 required
                  • id required - string

                    Resource ID.

              • remoteAddressSpace optional
                  • addressPrefixes required - array

                    A list of address blocks reserved for this virtual network in CIDR notation.

              • remoteBgpCommunities optional
                  • virtualNetworkCommunity required - string

                    The BGP community associated with the virtual network.

              • peeringState optional - string

                The status of the virtual network peering.

          • name required - string

            The name of the resource that is unique within a resource group. This name can be used to access the resource.

      • enableDdosProtection optional - boolean

        Indicates 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 - boolean

        Indicates if VM protection is enabled for all the subnets in the virtual network.

      • ddosProtectionPlan optional
          • id required - string

            Resource ID.

      • bgpCommunities optional
          • virtualNetworkCommunity required - string

            The BGP community associated with the virtual network.

      • ipAllocations optional array
          • id required - string

            Resource ID.

Frequently asked questions

What is Azure Network DNS Servers?

Azure Network DNS Servers is a resource for Network of Microsoft Azure. Settings can be wrote in Terraform.