Comprehensive Guide to Troubleshoot DNS Filters in FortiGate

Published on: 09-14-2023 By Ashish Magoo

Troubleshooting for DNS filter

If you have trouble with the DNS filter profile in your policy, start with the following troubleshooting steps:

  • Check the connection between the FortiGate and FortiGuard DNS rating server (SDNS server).
  • Check that the FortiGate has a valid FortiGuard web filter license.
  • Check the FortiGate DNS filter configuration.

Checking the connection between the FortiGate and FortiGuard SDNS server

You need to ensure the FortiGate can connect to the FortiGuard SDNS server. By default, the FortiGate uses DNS over TLS (DoT, TCP port 853) to connect to the SDNS server. See DNS over TLS and HTTPS for more information.

To check the connection between the FortiGate and SDNS server:

  1. Verify the FortiGuard SDNS server information:
    # diagnose test application dnsproxy 3
    ... SDNS servers: 173.243.140.53:853 vrf=0 tz=-480 encrypt=dot req=0 to=0 res=0 rt=34 ready=1 timer=0 probe=0 failure=0 last_failed=0
    The SDNS server IP address might be different depending on location (in this example, it is 173.243.140.53:853).
  2. In the management VDOM, check the communication between the FortiGate and the SDNS server:
    # execute ping 173.243.140.53
  3. If FortiGuard is not reachable using anycast, configure the default FortiGuard SDNS (unicast) server (208.91.112.220):
    config system fortiguard
    set fortiguard-anycast disable
    set sdns-server-ip "208.91.112.220"
    end

    Verify the list of SDNS servers again:
    # diagnose test application dnsproxy 3
    FGD_DNS_SERVICE_LICENSE: server=208.91.112.220:53, expiry=2023-10-28, expired=0, type=2
    server=83.231.212.53:53, expiry=2023-10-28, expired=0, type=2
  4. The default FortiGuard SDNS server should work in most cases; however, you can switch to another server to see if it improves latency.
  5. By default, DNS filtering connects to the FortiGuard secure DNS server over anycast and uses DoT (TCP port 853) when the default settings of fortiguard-anycast enable and fortiguard-anycast-source fortinet are configured. Disabling fortiguard-anycast will force the FortiGate to use cleartext (UDP port 53) instead of DoT (TCP port 853) in addition to disabling FortiGuard secure DNS over anycast.

Checking the FortiGuard DNS rating service license

The FortiGuard DNS rating service shares the license with the FortiGuard web filter, so you must have a valid web filter license for the DNS rating service to work. While the license is shared, the DNS rating service uses a separate connection mechanism from the web filter rating.

To check the DNS rating service license in the CLI:

  1. View the DNS settings:
    # diagnose test application dnsproxy 3
  2. Find the FGD_DNS_SERVICE_LICENSE line and check that the license has not expired:
    FGD_DNS_SERVICE_LICENSE: server=173.243.140.53:853, expiry=2023-10-28, expired=0, type=2

Checking the FortiGate DNS filter profile configuration

To check the DNS filter profile configuration:

  1. In FortiOS, create a local domain filter and set the Action to Redirect to Block Portal (see Local domain filter).
  2. Apply this DNS filter profile to the policy.
  3. From the client PC, perform a DNS query on this domain.
  4. If you get the profile's redirected portal address, this means that the DNS filter profile works as expected.

Additional troubleshooting

Use diagnose test application dnsproxy <test level> to troubleshoot further DNS proxy information, where:

  • Test level 1: Clear DNS cache
  • Test level 2: Show statistics
  • Test level 3: Dump DNS setting
  • Test level 4: Reload FQDN
  • Test level 5: Requery FQDN
  • Test level 6: Dump FQDN
  • Test level 7: Dump DNS cache
  • Test level 8: Dump DNS database
  • Test level 9: Reload DNS database
  • Test level 10: Dump secure DNS policy/profile
  • Test level 11: Dump botnet domain
  • Test level 12: Reload secure DNS setting
  • Test level 13: Show hostname cache
  • Test level 14: Clear hostname cache
  • Test level 15: Show SDNS rating cache
  • Test level 16: Clear SDNS rating cache
  • Test level 17: Show DNS debug bit mask
  • Test level 18: Show DNS debug object members
  • Test level 99: Restart the dnsproxy worker

To debug DNS proxy details:
# diagnose debug application dnsproxy -1
# diagnose debug {enable | disable}