DNS filter: stopping a site when its name is looked up
This lesson is open to everyone. The other lessons open with a package: sign in or sign up, then choose a package.
Key points
- The DNS filter looks at the DNS query, not the connection: for a forbidden name it returns the address of a block page instead of the real IP, or gives no answer.
- It works even when traffic is encrypted and needs no SSL inspection, because an ordinary DNS query is plain text. It is light and covers every protocol, not only the web.
- Its weak side: it sees only the domain name. It does not see the specific page or the downloaded file.
- Botnet C&C blocking stops an infected computer from finding the name of its control server.
- If a computer uses encrypted DNS (DoH, DoT) or types the IP directly, the DNS filter does not see it. That is why it is used together with the web filter.
The idea
To open a site a computer first asks: "what is the IP of www.example.com?" If it gets no answer, the connection never starts.
The DNS filter catches this query as it passes through the FortiGate, learns the category of the name from FortiGuard and decides:
- if it is allowed, the answer passes unchanged;
- if it is forbidden, the computer receives the address of the block portal instead of the real IP (redirect), or the answer is blocked altogether.
How it differs from the web filter
| DNS filter | Web filter | |
|---|---|---|
| What it looks at | The name in the DNS query | The HTTP/HTTPS connection |
| SSL inspection needed | No | At least certificate inspection |
| Coverage | Every protocol (web, mail, any application) | Web only |
| Precision | Domain only | Domain; the full address with deep inspection |
| Resource use | Very low | Higher |
| Ways around it | Typing the IP directly, encrypted DNS | Hard |
The two are not rivals; they complement each other. The DNS filter is a cheap first layer: it cuts most malicious domains before a connection starts. The web filter is the second, more precise layer.
The profile
FGT-HQ # config dnsfilter profile FGT-HQ (profile) # edit "DNS-OFIS" FGT-HQ (DNS-OFIS) # set block-botnet enable FGT-HQ (DNS-OFIS) # config ftgd-dns FGT-HQ (ftgd-dns) # config filters FGT-HQ (filters) # edit 1 FGT-HQ (1) # set category 26 FGT-HQ (1) # set action block FGT-HQ (1) # next FGT-HQ (filters) # edit 2 FGT-HQ (2) # set category 61 FGT-HQ (2) # set action block FGT-HQ (2) # next FGT-HQ (filters) # edit 3 FGT-HQ (3) # set category 11 FGT-HQ (3) # set action block FGT-HQ (3) # next FGT-HQ (filters) # end FGT-HQ (ftgd-dns) # end FGT-HQ (DNS-OFIS) # next FGT-HQ (profile) # end
GUI: Security Profiles > DNS Filter. The categories are the same as in the web filter (26 Malicious Websites, 61 Phishing, 11 Gambling).
The main settings:
| Setting | What it does |
|---|---|
| FortiGuard category filter | allow / monitor / block (redirect to block portal) by category |
block-botnet | Blocks queries for known botnet control (C&C) domains |
| Static domain filter | Your own list: block / allow / monitor for specific domains |
| DNS translation | Replaces the IP in an answer with another one |
| Safe search | Steers search engines into safe mode |
Attaching it to a policy
The DNS filter is attached to the policy through which DNS traffic passes. If computers use an external DNS server (for example 9.9.9.9), that is the LAN → internet policy, and its services must include DNS.
FGT-HQ # config firewall policy FGT-HQ (policy) # edit 1 FGT-HQ (1) # set utm-status enable FGT-HQ (1) # set dnsfilter-profile "DNS-OFIS" FGT-HQ (1) # next FGT-HQ (policy) # end
If computers use the FortiGate itself as their DNS server (dns-service local in DHCP, lesson 5), the profile is attached not to a policy but to the FortiGate's DNS server service: Network > DNS Servers, select the interface and name the DNS filter profile.
What is botnet C&C?
An infected computer does not act on its own: it connects to the attacker's command and control (C&C) server and waits for orders. Because the server address changes often, malware usually finds it by domain name.
With block-botnet enable the FortiGate blocks DNS queries for known C&C domains. This has two benefits: the malware cannot receive orders, and in the log you see which computer is infected. An internal IP that appears in the botnet log is a computer to check at once.
Limitations
- Direct access by IP. With no DNS query the DNS filter does nothing.
- Encrypted DNS. If a browser uses DNS over HTTPS (DoH), the query travels inside ordinary HTTPS traffic. To prevent this, known DoH servers are blocked with application control or the web filter so that the browser falls back to ordinary DNS.
- Precision. One domain can hold both useful and harmful pages; the DNS filter cannot tell them apart.
Watch out on a real device: if the FortiGuard DNS rating service cannot be reached, queries may be blocked by default and to staff it looks like "the internet is down". The Allow DNS requests when a rating error occurs option in the profile changes this. Keep an eye on the licence expiry date: the DNS filter also depends on the web filter licence.
Verifying
Look up a blocked domain on a computer:
C:\> nslookup gambling.example.comIf the answer is not the site's real IP but the address of the FortiGuard block portal, the filter works. Logs in the GUI: Log & Report > Security Events > DNS Query.
🧪 Hands-on lab · Device: FortiGate-VM
DNS filter profile
Create a DNS filter profile called DNS-OFIS: block botnet C&C domains (set block-botnet enable) and under config ftgd-dns → config filters write block for category 26 (Malicious Websites). Attach the profile to policy 1.
Checked:
- block-botnet enable
- Category 26: block
- Policy 1: DNS-OFIS
Check yourself
5 questions · answers are shown instantly · 3 correct answers complete the lesson
1What does the DNS filter look at?
2Is SSL inspection needed for the DNS filter?
3A user types the IP address of a site straight into the browser. What does the DNS filter do?
4What does the block-botnet option block?
5What is the right relationship between the DNS filter and the web filter?
Comments
Sign in to comment.