Implementing Azure DNS Forwarder is a great way to efficiently resolve names within your Azure infrastructure. This solution allows you to forward DNS queries to an Azure DNS zone, improving performance and reducing latency.
With Azure DNS Forwarder, you can easily manage DNS records for your Azure resources, including virtual machines, load balancers, and storage accounts. This centralized management streamlines DNS resolution and reduces the administrative burden.
By using Azure DNS Forwarder, you can also take advantage of Azure's built-in security features, such as DNSSEC and Azure Active Directory integration. This provides an additional layer of security and authentication for your DNS queries.
Azure DNS Forwarder supports multiple DNS protocols, including UDP and TCP, allowing you to choose the protocol that best suits your needs.
Azure DNS Forwarder Configuration
Azure DNS Forwarder Configuration is a crucial step in setting up a reliable and efficient DNS resolution system. You can configure Azure DNS Forwarder to forward DNS queries from your on-premise network to Azure DNS.
To configure DNS Forwarding Ruleset, you need to add a forwarding rule for the contoso.internal domain to the on-premise DNS inbound IP address, 10.233.2.4:53. This will allow hub and spokes networks to resolve the on-premise-vm.contoso.internal domain.
A Forwarding Ruleset is a collection of rules that define how DNS queries are forwarded. You can have multiple Forwarding Rulesets, each with its own set of rules.
To configure a Forwarding Ruleset, you need to add a forwarding rule for the privatelink.postgres.database.azure.com domain to the Azure DNS inbound IP address, 10.221.2.4:53. This will allow on-premise networks to resolve privatelink DNS queries.
Inbound endpoints provide an IP address to forward DNS queries from on-premises and other locations outside your virtual network. The IP address associated with an inbound endpoint is always part of the private virtual network address space where the private resolver is deployed.
Here's an example of how to configure a Forwarding Ruleset for a privatelink PostgreSQL domain:
- Add a Forwarding Rule for privatelink.postgres.database.azure.com. domain to Azure DNS inbound IP address, 10.221.2.4:53
- Check that privatelink DNS resolution from on-premise network is now possible
You can also use inbound endpoints as custom DNS for a VNet. This configuration can replace instances where you're using your own DNS server as custom DNS in a VNet.
Here's a summary of the steps to configure Azure DNS Forwarder:
- Add a forwarding rule for the contoso.internal domain to the on-premise DNS inbound IP address, 10.233.2.4:53
- Add a forwarding rule for the privatelink.postgres.database.azure.com domain to the Azure DNS inbound IP address, 10.221.2.4:53
- Configure inbound endpoints to forward DNS queries from on-premises and other locations outside your virtual network
Note: The IP addresses and domain names used in these examples are fictional and for illustration purposes only.
Name Resolution
Name resolution is a crucial aspect of Azure DNS forwarder, and understanding how it works is essential for a smooth experience. Azure-provided name resolution provides only basic authoritative DNS capabilities, but it's a good starting point for most deployment scenarios.
You can't control the DNS zone names or the life cycle of DNS records with Azure-provided name resolution. If you need a fully featured DNS solution, you can use Azure Private DNS zones with Customer-managed DNS servers or Azure DNS Private Resolver.
Azure provides internal name resolution for VMs and role instances that reside within the same virtual network or cloud service. This means you can access internal IP addresses of role instances using the Azure Service Management REST API.
However, in virtual networks deployed using the classic deployment model, different cloud services have different DNS suffixes. In this case, you need the FQDN to resolve names between different cloud services.
You can assign DNS names to both VMs and network interfaces. Azure-provided name resolution doesn't require any configuration, but it's not the appropriate choice for all deployment scenarios.
Here are some deployment scenarios where you might need to specify your own DNS servers:
- Virtual networks deployed using the classic deployment model
- Network interfaces or cloud services that require custom DNS settings
- Virtual networks that require custom DNS settings
In these scenarios, you can specify multiple DNS servers per virtual network, network interface, or cloud service. DNS servers specified for a network interface or cloud service get precedence over DNS servers specified for the virtual network.
If you opt for custom DNS server for your virtual network, you must specify at least one DNS server IP address. Otherwise, the virtual network ignores the configuration and uses Azure-provided DNS instead.
To ensure that new DNS settings take effect, you must perform a DHCP lease renewal on all affected VMs in the virtual network. The steps vary depending on the OS, but you can enter `ipconfig /renew` directly in the VM for Windows OS.
Private Resolver and VPNs
When working with Azure DNS Private Resolver and VPNs, it's essential to understand how they interact. A VPN client will get assigned a DNS server based on the custom DNS server configured in the VNet containing the VPN gateway.
The custom DNS server is typically set to the Azure Firewall's IP address, which in this case is 192.168.1.4. This means that a VPN client will receive 192.168.1.4 as its DNS server.
To verify connectivity, you can test domain resolution from a VPN client. This involves checking if the client can resolve hostnames and obtain their IP addresses.
Private Resolver
To set up a Private Resolver, you'll first need to open the Dns Forwarding Ruleset in the hub-rg.
To access the DNS settings, you'll have two options to choose from.
To manage your Private Resolver, start by opening the Dns Forwarding Ruleset in the hub-rg.
Private VPNs
Private VPNs can be a bit tricky to set up, but understanding the basics can make all the difference.
A Private Resolver and Point-to-Site VPN is a great combination for secure and private connections.
In Azure, a P2S client will get assigned a DNS server based on the custom DNS server configured in the VNet containing the VPN gateway. This means if the hub VNet has a custom DNS server, it will be the one assigned to the VPN client.
The Azure Firewall's IP address can be set as the custom DNS server in the hub VNet, which is exactly what happened in our setup. The DNS server was set to 192.168.1.4, and it worked like a charm.
To test connectivity, we verified that our system could get the IP addresses for the hostnames we were testing. This is a crucial step in ensuring our VPN setup is working correctly.
Now, let's talk about what happens when we try to resolve domain names. We can use tools like traceroute to see how our traffic is routed through the VPN Gateway, which is transparent to traceroute.
Configuration and Deployment
In order to unlock DNS resolution capabilities, you'll need to configure DNS Forwarding Ruleset for both Hub and On-premise networks. This will allow "*.contoso.internal" DNS resolution from hub & spokes networks and enable private DNS resolution for "*.postgres.database.azure.com" from on-premise networks.
To do this, you can follow the steps outlined in the DNS Forwarding Ruleset configuration. This involves configuring DNS Servers on Hub & Spokes vnets with the private IP address of Azure Firewall, or using Option b:.
Here are the two configuration options:
- Hub & Spokes vnets will have their DNS Servers configured with the private IP address of Azure Firewall
- Option b: ( details not specified in the article section)
Deploy Firewall for Log Access
Deploying a firewall is a crucial step in gaining access to DNS logs.
You have two options for configuring your DNS servers to forward requests to Azure Firewall.
To deploy Azure Firewall as a DNS proxy, you'll need to configure it to forward all DNS requests to the Azure DNS Private Resolver's inbound IP address.
You can choose between two options for configuring your hub and spokes virtual networks: Option a involves configuring the DNS servers with the private IP address of Azure Firewall, while Option b is left blank in the example, leaving it up to you to decide the best approach for your setup.
Configure Firewall
To configure Azure Firewall, you'll need to deploy it and use it as a DNS proxy. This involves configuring Azure Firewall to forward all DNS requests to Azure DNS Private Resolver inbound IP address.
You can configure Azure Firewall as a DNS Proxy by setting it up to act as a DNS proxy. This will allow you to capture DNS logs.
There are two options for configuring the DNS servers in your Hub & Spokes vnets: Option a and Option b. Option a involves configuring the DNS servers with the private IP address of Azure Firewall.
To configure Azure Firewall as a DNS proxy, you'll need to update the Azure DNS Forwarding Ruleset. This involves creating two different rulesets: one for the hub and one for the spoke(s).
Here are the key steps to update the Azure DNS Forwarding Ruleset:
- Remove unnecessary rules from the hub Forwarding Ruleset
- Link the spoke Forwarding Ruleset to the spoke01-vnet
- Complete the rules of the spoke Forwarding Ruleset
By following these steps, you'll be able to configure Azure Firewall to capture DNS logs and resolve DNS names correctly.
Update On-Premise
To update on-premise DNS Forwarding Ruleset, you'll need to point requests to Azure Firewall private IP address in the hub instead of DNS Private Resolver Inbound IP address.
The private IP address you'll need to point to is 10.221.2.4:53, which is the Azure DNS inbound IP address.
You'll also need to update the forwarding rule to point to the Azure Firewall private IP address in the hub.
Here's a summary of the changes you'll need to make:
- Update the forwarding rule to point to the Azure Firewall private IP address in the hub: 10.221.2.4:53
This will allow Azure Firewall to handle DNS resolution for the privatelink.postgres.database.azure.com domain and contoso.azure domains.
Links
Links play a crucial role in configuring and deploying a distributed DNS architecture in Azure. You can link a ruleset to a virtual network, enabling resources within that network to use the DNS forwarding rules enabled in the ruleset.
To link a ruleset to a virtual network, you don't need the linked virtual networks to peer with the virtual network where the outbound endpoint exists, but they can be configured as peers in a hub and spoke design.
Resources in a virtual network can resolve records in a private DNS zone if the ruleset provisioned in the virtual network is linked to it, and a ruleset rule is configured and enabled to resolve the zone using the inbound endpoint in the virtual network.
You can also link a ruleset to a virtual network in another Azure subscription, but the resource group specified must be in the same region as the private resolver.
Here are some key points to keep in mind when linking a ruleset to a virtual network:
- The ruleset must be linked to the virtual network for resources in the network to use the DNS forwarding rules.
- The virtual network with the private resolver must be linked from any private DNS zones for which there are ruleset rules.
- The resource group specified in the linked ruleset must be in the same region as the private resolver.
In a hub and spoke design, the spoke virtual network doesn't need to be linked to the private DNS zone to resolve resource records in the zone, as long as the forwarding ruleset rule for the private zone sends queries to the hub virtual network's inbound endpoint.
Logging and Results
You've successfully deployed a basic Azure and On-Premises environment using a Terraform template, and you're now able to login to all VMs using your specified credentials via Serial Console.
Privatelink DNS resolution is working from Azure hub & spokes networks, allowing for end-to-end network connectivity from On-Premise to Azure.
To verify this, you can check that Privatelink DNS resolution is working by generating DNS requests from spoke01-vm and displaying Azure Firewall DNS logs using a KQL query.
Generate Logs
Generating logs is a crucial step in monitoring and troubleshooting Azure Hub&spokes VMs. You can generate DNS requests from spoke01-vm, which is a specific task mentioned in the article.
To display Azure Firewall DNS logs, you'll need to use a KQL query, as shown in the article example. This query will provide you with the necessary information to analyze and troubleshoot DNS-related issues.
Azure Firewall DNS logs can be used to track and analyze DNS requests, helping you identify potential security threats or issues with your DNS configuration.
Here are some key tasks related to generating logs:
- Generate DNS requests from spoke01-vm
- Display Azure Firewall DNS logs using the following KQL query:
By following these steps and using the KQL query, you'll be able to effectively generate and display logs for your Azure Hub&spokes VMs.
Results
In this section, we'll review the results of our efforts. You have successfully deployed a basic Azure and On-Premises environment using a Terraform template.
A key aspect of this achievement is that you're now familiar with the components you've deployed in your subscription. This knowledge is crucial for future maintenance and troubleshooting.
To verify end-to-end network connectivity, we've confirmed that it's working from On-Premise to Azure. This is an essential step in ensuring seamless communication between your environments.
You're also able to login to all VMs using your specified credentials via Serial Console. This level of access is vital for monitoring and managing your virtual machines.
Privatelink DNS resolution is working from Azure hub & spokes networks. This means that your DNS queries are being resolved correctly within your network infrastructure.
Frequently Asked Questions
What does a DNS forwarder do?
A DNS forwarder forwards external DNS queries to outside servers, ensuring your network can access online resources efficiently. Adding a DNS forwarder to your configuration can improve your site's online performance and reliability.
Sources
- https://learn.microsoft.com/en-us/azure/dns/private-resolver-endpoints-rulesets
- https://learn.microsoft.com/en-us/azure/virtual-network/virtual-networks-name-resolution-for-vms-and-role-instances
- https://autosysops.com/blog/cloud-native-dns-resolver-in-azure
- https://github.com/davidsntg/azure-dns-private-resolver-microhack
- https://blog.cloudtrooper.net/2022/11/13/azure-dns-private-resolver-without-vnet-peerings/
Featured Images: pexels.com