Tutorials · Security Operations

How to Block Malware and Phishing Domains With DNS Filtering

Most malware and phishing needs DNS to reach its servers. Filter DNS for every device on the network with your own resolver and blocklists, and stop users bypassing it.

Beginner12 min6 steps

Before you start

  • A small Linux server or edge server with Docker
  • Admin access to DHCP and the gateway firewall

Step by step

  1. Run a filtering resolver

    AdGuard Home and Pi-hole are free, self-hosted DNS filters. Example with AdGuard Home in Docker:

    docker run -d --name dnsfilter --restart unless-stopped \
      -p 53:53/tcp -p 53:53/udp -p 3000:3000/tcp \
      -v /opt/dnsfilter/work:/opt/adguardhome/work \
      -v /opt/dnsfilter/conf:/opt/adguardhome/conf \
      adguard/adguardhome
    
  2. Complete the setup

    Open http://<server>:3000, set an admin password, choose upstream resolvers and enable malware and phishing blocklists.

  3. Point clients to it

    Set the filter's IP as the DNS server in every DHCP scope. Keep a second filter server for redundancy.

  4. Stop DNS bypass

    Block outbound DNS (UDP/TCP 53) from user VLANs except from your DNS servers, and block known public DNS-over-HTTPS endpoints where policy allows.

  5. Test

    Query a known test domain from your blocklist and confirm it is blocked, while normal sites resolve.

    dig @10.1.10.5 www.example.com
    dig @10.1.10.5 <blocked-test-domain>
    
  6. Review the logs

    Blocked queries show infected or misbehaving devices. Investigate repeated blocks from the same host.

Commands are generic, industry-standard examples. Exact syntax and menu names vary by model and firmware; check your device's manual on the Documentation page.

Pro tips

  • Allow-list business domains that are blocked by mistake, and document why.
  • Log retention may contain personal data: set retention according to your policy.