Best Practices for Configuring DNS Context Profiles in FQDN-Based Distributed Firewall (DFW) Rules
search cancel

Best Practices for Configuring DNS Context Profiles in FQDN-Based Distributed Firewall (DFW) Rules

book

Article ID: 457796

calendar_today

Updated On:

Products

VMware vDefend Firewall VMware vDefend Firewall with Advanced Threat Prevention

Issue/Introduction

When configuring Fully Qualified Domain Name (FQDN) filtering in VMware vDefend Distributed Firewall (DFW), Layer 7 (L7) DNS context profiles must be applied efficiently. Broadly applying L7 DNS context profiles across large scopes or targeting DNS infrastructure directly can lead to unnecessary processing overhead.

This KB article outlines the available approaches and configurations to keep DNS L7 inspection client-focused and optimized.

 

Environment

VMware vDefend Distributed Firewall (Formerly NSX Distributed Firewall)
VMware vDefend Firewall with Advanced Threat Prevention.

Resolution

FQDN filtering lets the DFW allow or deny traffic by domain name, such as *.example.com. It is a Layer 7 feature that relies on DNS snooping to map IP addresses to FQDNs. The firewall builds and maintains that mapping from the DNS responses returned to the workload.

For FQDN filtering to work as documented:

  • Workloads must resolve names through a DNS server. Static DNS entries are not supported.
  • Workloads must honor the TTL received in the DNS response.
  • For proper FQDN enforcement, the DFW rule specifying the DNS service and context profile must be applied to the client workloads, not the DNS servers.

The product documentation shows the DNS rule with Source and Destination of "Any or specific group" and Applied To of "a group as required". How broadly you scope that rule is up to you. This article gives some available approaches.

Why scope matters

DNS queries originate on the client workload, so the client is where FQDN learning and enforcement matter. Applying the DNS L7 context profile to DNS servers, or to a very large Any/Any scope, causes L7 inspection of traffic that does not need it. Because L7 inspections require deeper packet analysis, they are much more CPU-intensive than standard L4 rules.

Implementation Options:

  1. Apply the DNS context profile to a granular group of DNS clients

1a. Create a group containing only the workloads that need FQDN enforcement, and use it as the "Applied To" value for the DNS context profile rule.

    1. Use dynamic membership (for example, tag- or name-based criteria) so the group stays current as workloads are added or removed.
    2. Align the group with the workloads targeted by your FQDN allowlist or denylist rules.

1b. Create another L4 allow rule that is applied only to the DNS Servers.

OR

2. Exclude DNS servers with a higher-priority L4 DNS rule (if clients are hard to identify)

If you cannot easily identify all the DNS clients(Workload VMs), use a higher-priority L4 rule to keep DNS servers out of L7 inspection:

    1. Create a group containing your DNS servers.
    2. Add a rule above the DNS context profile rule with the DNS-TCP and DNS-UDP services, no context profile, and Action = Allow.
    3. Scope the rule so that it matches DNS server traffic (for example, Applied To = the DNS server group).

Traffic matching this L4 rule is handled at Layer 4 and does not reach the L7 DNS rule below it.

OR

3. Set Direction = OUT on the DNS context profile rule

3a. Configure the DNS context profile rule with Direction = OUT so that inspection is performed on traffic leaving the client workload. This matches the DNS query flow and avoids unnecessary inspection on the DNS server side.

3b. Create another L4 rule to allow traffic with Direction = IN and apply that to DNS servers.