Azure Virtual Network DNS servers are an essential component of your cloud infrastructure, responsible for translating domain names into IP addresses that your devices can understand.
In Azure, you can use the built-in DNS servers or create your own custom DNS servers using Azure DNS.
Azure Virtual Network DNS servers can be configured to use either the default DNS servers provided by Azure or custom DNS servers that you create.
The default DNS servers provided by Azure are highly available and scalable, making them a great choice for most use cases.
Azure Virtual Network DNS Basics
Azure-provided name resolution is a convenient option, but it's not suitable for all deployment scenarios. It provides only basic authoritative DNS capabilities and doesn't allow control over DNS zone names or the life cycle of DNS records.
Azure manages the DNS zone names and records if you use the DNS provided by Azure. You can use Azure Private DNS zones with Customer-managed DNS servers or Azure DNS Private Resolver for a fully featured DNS solution.
Azure-provided name resolution includes the following features:
- You don't need to configure anything.
- You don't need to create and manage clusters of your own DNS servers because of high availability.
- You can use the service with your own DNS servers to resolve both on-premises and Azure hostnames.
- You can use name resolution between VMs and role instances within the same cloud service, without the need for an FQDN.
- You can use name resolution between VMs in virtual networks that use the Resource Manager deployment model, without need for an FQDN.
- You can use hostnames that best describe your deployments, rather than working with autogenerated names.
In virtual networks deployed by using the Azure Resource Manager deployment model, the DNS suffix is consistent across all the VMs within a virtual network, so the FQDN isn't needed.
Configuring Client and VMs
You can check the current DNS client configuration on a Linux VM by using the command cat /etc/resolv.conf.
Looking at the options line, you'll see settings such as nameservers, search domains, and options like rotate and timeout. The nameservers line lists the IP addresses of the DNS servers that the VM will use to resolve domain names.
Client Configuration
Configuring client settings is essential for a smooth connection to the internet. You can check the current DNS client configuration on a Linux VM by running the command cat /etc/resolv.conf.
The options line in this file will display the current DNS settings. For example, it might look something like this.
To verify the DNS client configuration, you can use the same command as above. This will give you a clear picture of the current settings.
VMs and Roles
VMs are the backbone of a virtualized environment, and understanding how they relate to roles is crucial for efficient configuration.
A VM, or virtual machine, is essentially a self-contained operating system that can run independently of the physical hardware it's hosted on.
Roles, on the other hand, are pre-defined sets of permissions and access rights that determine what actions a user can perform within a VM.
For example, a VM might be set up with a role that allows only read-only access to certain files, while another role might grant full administrator privileges.
By assigning roles to users, you can control who has access to sensitive data and prevent unauthorized changes to critical systems.
In a typical setup, a VM might be configured with multiple roles, each with its own set of permissions and access rights.
This allows administrators to manage user access and permissions with precision, while also ensuring that sensitive data remains secure.
VMs can also be configured to automatically assign roles based on user identity or group membership.
This can simplify user management and reduce the risk of human error when assigning roles.
Example: Hosts File
The hosts file is a crucial document for Linux, macOS, and Windows users alike. It's used to override name resolution for the local computer.
The hosts file contains a list of IP addresses and the corresponding host name. This allows the local computer to resolve a host name to a specific IP address.
You can find the hosts file in different locations depending on your operating system. Here's a quick rundown:
To edit the hosts file, you'll need administrator access. This is because the file is protected by default. On Linux and macOS, you can use `sudo vi` to edit the file. On Windows, you can run Notepad as an administrator to make changes.
The hosts file has no extension, and its name is simply "hosts".
Retrieve Endpoint FQDNs
To retrieve endpoint FQDNs, you'll need to use the "Get-ADComputer" cmdlet, which is used to retrieve information about a computer account in the Active Directory.
You can specify the computer name or the distinguished name to uniquely identify the computer account.
The "Get-ADComputer" cmdlet can be used to retrieve the FQDN of the computer, which is the fully qualified domain name of the computer.
For example, if you want to retrieve the FQDN of a computer named "client1" in the domain "example.com", you would use the command "Get-ADComputer -Identity client1 -Properties FQDN".
The FQDN is retrieved from the "FQDN" attribute of the computer account.
In this case, the output would be "client1.example.com".
You can also use the "Get-ADComputer" cmdlet to retrieve a list of all computers in the domain, along with their FQDNs.
For example, if you want to retrieve a list of all computers in the domain "example.com", you would use the command "Get-ADComputer -Filter * -Properties FQDN".
Using Zones
You can use Private DNS Zones to resolve names for resources in a private network. These zones enable you to manage DNS records in a VNet, and you can link as many VNets as you want to the same Private DNS Zone.
You can use Public DNS Zones in Azure, which is just DNS as you know it, but managed in Azure. This allows you to use RBAC to manage access to your DNS records as you do for any other Azure resources.
Private DNS Zones work across regions and can be linked to multiple VNets at the same time. You can register the names of virtual machines in a Private DNS Zone automatically using the auto registration feature.
To use Private DNS Zones, you can link them to VNets and enable auto registration. This will automatically add and remove records for new and deleted VMs, as well as update records when VMs are stopped and deallocated.
Here are some key features of Private DNS Zones:
- Private DNS Zones enable you to resolve names for resources in a private network.
- Records are only resolvable from within a linked VNet and not from the outside.
- Private DNS Zones work across regions and can be linked to multiple VNets at the same time.
- You can register the names of virtual machines in a Private DNS Zone automatically using the auto registration feature.
You can also use Split-Horizon DNS to create a Private DNS Zone with the same name as a Public DNS Zone. This allows you to override the public zone and point to private IP addresses within your network.
Advanced DNS Capabilities
In Azure Virtual Network, Private DNS Zones are a powerful tool for managing your network's DNS.
Public DNS Zones are relatively straight-forward, but Private DNS Zones have more advanced capabilities.
Private DNS Zones can be used to leverage their power by implementing advanced private DNS capabilities.
One key concept is that of Private DNS Zones, which allow you to manage your network's DNS in a more controlled environment.
Private DNS Zones can be used to create and manage custom DNS records, giving you more flexibility and control over your network's DNS.
By using Private DNS Zones, you can create a more secure and private DNS environment for your network.
Private DNS Zones can be used to implement advanced security features, such as DNS filtering and blocking.
You can also use Private DNS Zones to create and manage conditional forwarding, which allows you to forward DNS queries to other DNS servers based on specific conditions.
Private DNS Zones can be used to implement advanced load balancing and traffic management features.
By using Private DNS Zones, you can create a more efficient and scalable DNS environment for your network.
Troubleshooting and Best Practices
If you're experiencing issues accessing the workspace from a virtual machine or jobs failing on compute resources in the virtual network, use the following steps to identify the cause. These steps have helped me resolve similar issues in the past.
To start, locate the workspace FQDNs on the Private Endpoint by navigating to the Azure portal and accessing the Private Endpoint to the Azure Machine Learning workspace. The workspace FQDNs will be listed on the "Overview" tab.
Accessing compute resources in the Virtual Network topology can be done by proceeding to access a compute resource in the Azure Virtual Network topology, which may require accessing a Virtual Machine in a Virtual Network that is peered with the Hub Virtual Network.
If the nslookup command doesn't return one of the two private IP addresses on the Private Endpoint to the Azure Machine Learning workspace, then there is something misconfigured in the custom DNS solution.
Here are the possible causes to consider:
- Incorrect configuration of the custom DNS solution
- Missing or incorrect workspace FQDNs
Considerations
The Azure-provided name resolution has some key considerations to keep in mind.
The Azure-created DNS suffix can't be modified, so it's essential to choose a suffix that works for your setup.
DNS lookup is scoped to a virtual network, meaning DNS names created for one virtual network can't be resolved from other virtual networks.
To avoid DNS resolution issues, a different name must be used for each VM in a virtual network.
Azure DNS IP address is 168.63.129.16, a static IP address that doesn't change.
VMs in the first 180 cloud services are registered for each virtual network in a classic deployment model, but this limit doesn't apply to virtual networks in Resource Manager.
Here's a list of client operating systems that require client-side caching and client-side retries:
- RHEL
- openSUSE, SLES
- Ubuntu, Debian
This is essential to prevent request throttling, which can be mitigated by enabling client-side caching.
Prerequisites and Setup
To set up Azure Virtual Network DNS servers, you'll need to start with a few prerequisites. You'll need an Azure Virtual Network that uses your own DNS server.
You'll also need an Azure Machine Learning workspace with a private endpoint. This is required for hub workspaces like those used by Azure AI Foundry, and can be created by following the instructions in the "Create an Azure Machine Learning workspace" article.
If your workspace dependency resources are secured with an Azure Virtual network, you should be familiar with the concept of Network isolation during training & inference. Additionally, you'll need to understand how to configure Azure Private Endpoint DNS zone configuration and Azure Private DNS.
Here's a quick rundown of the prerequisites:
- An Azure Virtual Network that uses your own DNS server.
- An Azure Machine Learning workspace with a private endpoint.
- Familiarity with Network isolation during training & inference.
- Familiarity with Azure Private Endpoint DNS zone configuration and Azure Private DNS.
- Optionally, Azure CLI or Azure PowerShell.
Prerequisites
To get started with Azure Machine Learning, you'll need to meet some prerequisites.
You'll need an Azure Virtual Network that uses your own DNS server. This is a crucial step, as it allows you to manage your network settings.
You'll also need an Azure Machine Learning workspace with a private endpoint. This is necessary for secure resource access.
Familiarity with Azure Private Endpoint DNS zone configuration and Azure Private DNS is also required. This will help you set up your network correctly.
Optional, but recommended, is familiarity with using the Azure CLI or Azure PowerShell. This will give you more flexibility when working with your Azure resources.
Here are the specific prerequisites you'll need to meet:
- An Azure Virtual Network that uses your own DNS server.
- An Azure Machine Learning workspace with a private endpoint.
- Familiarity with Azure Private Endpoint DNS zone configuration and Azure Private DNS.
- Optional: Azure CLI or Azure PowerShell.
Infra as Code
Infra as Code is a game-changer for managing infrastructure.
You can define everything in code, including Azure DNS, using tools like Bicep, ARM, Terraform, or any other Infra-as-Code tool.
Creating a Public DNS Zone using Bicep is really easy, and you can use these basic examples to create your own smart and reusable modules.
Combining output variables together with these basic building blocks can automatically create records for VM's, Load Balancers, and other resources you create in your infrastructure.
The Common Azure Resource Modules Library (CARML) library has great easy-to-use templates available for many resources, including Public DNS Zones + records in one module definition.
Using CARML modules can be a breeze for setting up everything, including VNet integrations, in just a few lines of code.
Managing DNS Records
To create A records in a custom DNS server, gather the list of FQDNs and corresponding IP addresses, and then proceed to create A records in the configured DNS Server. Refer to the documentation for your DNS server to determine how to create A records.
It's recommended to create a unique zone for the entire FQDN and create the A record in the root of the zone.
If you need to directly communicate with a service that uses a private endpoint, you may need to create a custom DNS record.
Example: Custom Server
In Terraform, you can configure custom DNS servers using the azurerm_virtual_network_dns_servers resource. This allows for a high degree of flexibility in managing DNS records.
The azurerm_virtual_network_dns_servers resource can be used to configure DNS servers in Azure virtual networks. This is particularly useful for custom server setups.
You can use the azurerm_virtual_network_dns_servers resource to add or remove DNS servers as needed, making it easy to manage custom DNS configurations.
Create a Records
To create A records in a custom DNS server, you'll need to gather the list of FQDNs and corresponding IP addresses. This will help you create a unique zone for the entire FQDN and add the A record in the root of the zone.
You can refer to the documentation for your DNS server to determine how to create A records. Some DNS servers may have specific requirements or steps to follow.
When creating A records, it's essential to note that some services may have multiple private-endpoints for sub-services or features. For example, an Azure Storage Account may have individual private endpoints for Blob, File, and DFS. If you need to access both Blob and File storage, you must enable resolution for each specific private endpoint.
To create A records, you can use the following steps:
- Create a unique zone for the entire FQDN.
- Add the A record in the root of the zone.
- Enable resolution for each specific private endpoint if necessary.
Here's an example of how to create A records:
Azure Virtual Network DNS Services
Azure Virtual Network DNS Services can be configured in Terraform using the resource name azurerm_virtual_network_dns_servers.
You can use custom DNS servers to perform name resolution from your web app to VMs in the same virtual network, but you'll need to set up a DNS forwarder that forwards queries to Azure (virtual IP 168.63.129.16).
Private Link is another option for using Private DNS Zones, which enables you to access Azure PaaS services from your VNets without exposing them to the internet.
To use Private Link, you'll need to deploy a Private Endpoint, a network interface that connects you privately to the resource, and link it to the PaaS service. This way, all traffic stays within your network and doesn't go over the internet.
Here are the steps to set up a Private Endpoint:
- Deploy a Private Endpoint: a network interface that connects you privately to the resource.
- Link the Private Endpoint to the PaaS service.
- Create a Private DNS Zone for the service and link it to the VNet.
Microsoft Azure Part 2
In Microsoft Azure, you can use custom DNS servers to perform name resolution between virtual networks. This involves setting up a DNS forwarder in each virtual network to forward queries to the recursive resolver in Azure, which is at virtual IP 168.63.129.16.
To set up a DNS forwarder, you'll need to create a VM in your target virtual network and install a DNS server that can forward queries to Azure. An example DNS forwarder is available in the Azure Quickstart Templates gallery and GitHub.
If you need to perform name resolution between virtual networks, you'll also need to set up a DNS forwarder in your source virtual network on a VM, configured to forward queries to the DNS server in your target virtual network.
To enable name resolution from your web app to VMs in the same virtual network, you'll need to enable virtual network integration for your web app, as described in Integrate your app with a virtual network.
Here are the steps to follow:
- Set up a DNS server in your target virtual network on a VM that can forward queries to the recursive resolver in Azure (virtual IP 168.63.129.16).
- Set up a DNS forwarder in the source virtual network on a VM, configured to forward queries to the DNS server in your target virtual network.
- Configure your source DNS server in your source virtual network's settings.
- Enable virtual network integration for your web app to link to the source virtual network.
Link
Private Link is a game-changer for accessing Azure PaaS services from within your VNets without exposing them to the internet.
Using Private Link, you can access services like Azure SQL Database, Azure Storage, or Azure Key Vault while keeping all traffic within your network. This is especially useful for services that require high security and low latency.
To set up Private Link, you deploy a Private Endpoint, a network interface that connects you privately to the resource. A Private Endpoint has to be linked to the PaaS service, and once that's complete, the resource is accessible from your VNet using the private IP address of the private endpoint.
Private DNS Zones play a crucial role in resolving the names of the private endpoints to their private IP addresses. You create a Private DNS Zone for the service and link it to the VNet, which then uses the Private DNS Zone to resolve the names of the private endpoints.
Using Private Endpoints can get expensive, especially if you use them extensively for many different services. Each endpoint costs a couple of dollars per month, and there's also a per-GB charge for all data processed, so be sure to check the Azure pricing calculator to see the impact.
The DNS resolution flow for Private Link involves querying the normal domain first, followed by Azure DNS trying to resolve the Private DNS zone before defaulting to the normal public DNS resolution flow.
Virtual Network Servers
Configuring DNS servers in Azure Virtual Network is a straightforward process. You can use the resource name azurerm_virtual_network_dns_servers in Terraform to set up DNS servers in your network.
This resource allows you to specify the DNS servers in your network. The azurerm_virtual_network_dns_servers resource is the key to configuring DNS servers in your Azure Virtual Network.
The resource name azurerm_virtual_network_dns_servers is specific to Terraform and is used to configure DNS servers in your network.
Dependency Services
Dependency services can be secured using a private endpoint, which requires creating a custom DNS record for direct communication. This is necessary for services like Azure Storage Account used by your workspace.
Some services have multiple private-endpoints for sub-services or features. For example, an Azure Storage Account may have individual private endpoints for Blob, File, and DFS.
To access both Blob and File storage, you must enable resolution for each specific private endpoint. This ensures that you can communicate directly with the service.
Azure Private Endpoint DNS configuration provides more information on the services and DNS resolution. If you're having trouble accessing your workspace, follow the steps outlined below to try to identify the cause.
To troubleshoot, locate the workspace FQDNs on the Private Endpoint. This can be done by navigating to the Azure portal and accessing the Private Endpoint to the Azure Machine Learning workspace. The workspace FQDNs will be listed on the "Overview" tab.
Possible causes of issues include misconfigured custom DNS solutions. To verify this, access a compute resource in the Azure Virtual Network topology and run an nslookup command for each workspace FQDN. The result should yield one of the two private IP addresses on the Private Endpoint to the Azure Machine Learning workspace.
Here are the steps to troubleshoot:
- Locate the workspace FQDNs on the Private Endpoint.
- Access a compute resource in the Azure Virtual Network topology.
- Resolve workspace FQDNs using the nslookup command.
Microsoft.Network/VirtualNetworks
Microsoft.Network/VirtualNetworks is a crucial component of Azure Virtual Network DNS Services. It's a resource that can be configured in Azure Resource Manager with the resource name Microsoft.Network/virtualNetworks.
The virtual network in Microsoft.Network requires a name, which is a string that must be provided. This name is a required parameter.
The type of virtual network is also a required parameter, specified as a string. This parameter determines the type of virtual network being created.
The API version of the resource is another required parameter, specified as a string. This parameter ensures that the resource is created with the correct version of the Azure Resource Manager API.
The location of the resource is also a required parameter, specified as a string. This parameter determines the region where the virtual network will be created.
Resource tags are optional parameters, specified as a string. These tags can be used to categorize and filter resources in Azure.
Here is a summary of the required parameters for Microsoft.Network/virtualNetworks:
Frequently Asked Questions
What is the DNS server IP for Azure VNET?
The default DNS server IP for Azure VNETs is 168.63.129.16. This IP is used for all Azure spoke virtual networks, which are also peered with the hub virtual networks.
What are the Azure DNS servers?
Azure DNS servers are hosted on Microsoft Azure infrastructure, providing a scalable and reliable name resolution service. They can be managed using the same credentials and tools as other Azure services.
Sources
- https://learn.microsoft.com/en-us/azure/virtual-network/virtual-networks-name-resolution-for-vms-and-role-instances
- https://learn.microsoft.com/en-us/azure/machine-learning/how-to-custom-dns
- https://loth.io/posts/everything-you-need-to-know-about-azure-dns/
- https://journeyofthegeek.com/2019/11/21/dns-in-microsoft-azure-part-2/
- https://shisho.dev/dojo/providers/azurerm/Network/azurerm-virtual-network-dns-servers/
Featured Images: pexels.com