DNS Request Filtering for Disallowed Website Domains
Overview of DNS Request Filtering
Starting in Junos OS Release 18.3R1, you can configure DNS filtering to identify DNS requests for disallowed website domains. Starting in Junos OS Release 19.3R2, you can configure DNS filtering if you are running Next Gen Services with the MX-SPC3 services card. Next Gen Services are supported on MX240, MX480 and MX960 routers. For DNS request types A, AAAA, MX, CNAME, TXT, SRV, and ANY, you configure the action to take for a DNS request for a disallowed domain. You can either:
Block access to the website by sending a DNS response that contains the IP address or fully qualified domain name (FQDN) of a DNS sinkhole server. This ensures that when the client attempts to send traffic to the disallowed domain, the traffic instead goes to the sinkhole server (see Figure 1).
Log the request and allow access.
Starting in Junos OS release 21.1R1, you can also configure the following actions for a DNS request for a disallowed domain:
- Alert
- Accept
- Drop
- Drop-no-log
For other DNS request types for a disallowed domain, the request is logged and access is allowed.
The actions that the sinkhole server takes are not controlled by the DNS request filtering feature; you are responsible for configuring the sinkhole server actions. For example, the sinkhole server could send a message to the requestor that the domain is not reachable and prevent access to the disallowed domain.

Benefits
DNS filtering redirects DNS requests for disallowed website domains to sinkhole servers, while preventing anyone operating the system from seeing the list of disallowed domains. This is because the disallowed domain names are in an encrypted format.
Disallowed Domain Filter Database File
DNS request filtering requires a disallowed domain filter database .txt file, which identifies each disallowed domain name, the action to take on a DNS request for the disallowed domain, and the IP address or fully qualified domain name (FQDN) of a DNS sinkhole server.
DNS Filter Profile
You configure a DNS filter profile to specify which disallowed domain filter database file to use. You can also specify the interfaces on which DNS request filtering is performed, limit the filtering to requests for specific DNS servers, and limit the filtering to requests from specific source IP address prefixes.
How to Configure DNS Request Filtering
To filter DNS requests for disallowed website domains, perform the following:
- How to Configure a Domain Filter Database
- How to Configure a DNS Filter Profile
- How to Configure a Service Set for DNS Filtering
How to Configure a Domain Filter Database
Create one or more domain filter database files that include an entry for each disallowed domain. Each entry specifies what to do with a DNS request for a disallowed website domain.
To configure a domain filter database file:
How to Configure a DNS Filter Profile
A DNS filter profile includes general settings for filtering DNS requests for disallowed website domains, and includes up to 32 templates. The template settings apply to DNS requests on specific uplink and downlink logical interfaces or routing instances, or to DNS requests from specific source IP address prefixes, and override the corresponding settings at the DNS profile level. You can configure up to eight DNS filter profiles.
To configure a DNS filter profile:
How to Configure a Service Set for DNS Filtering
[edit services service-set service-set-name] user@host# set web-filter-profile profile-name user@host# set syslog host hostname class urlf-logs user@host# set next-hop-service inside-service-interface interface-name.unit-number user@host# set next-hop-service outside-service-interface interface-name.unit-number
Multitenant Support for DNS Filtering
Overview
Starting in Junos OS Release 21.1R1, you can configure custom domain feeds per customer or IP subgroup. You can :
- Configure domain names and actions for multiple tenants such that domain feeds can be managed on a per tenant basis.
- Configure hierarchical domain feed management per profile, per dns-filter-template or per dns-filter-term.
- Exempt domain feeds at the IP, subnet, or CIDR level.
To implement the mutiltenant support for DNS filtering, creating the domain filter database file under template or profile level is disabled. You need not specify a file at the template or profile level. Starting in Junos OS 21.1R1, by default, a global file with a fixed name, nsf_multi_tenant_dn_custom_file.txt (plain text format) or dnsf_multi_tenant_dn_custom_file_hashed.txt (encrypted file) is available.
Each entry in the database file has the following items:
hashed-domain-name, IPv4 sinkhole address, IPv6 sinkhole address, sinkhole FQDN, ID, action, feed-name.
The file hash is calculated and appended to the list of domain name entries in the file.
The file hash is calculated using a global key and method ,which is validated with the file
hash computed using the hash key configured at the [edit services
web-filter]
hierarchy. The file validation is successful only if the calculated
file-hash matches the file hash present in the file.
Each entry in nsf_multi_tenant_dn_custom_file.txt file consists of an additional field called feed-name. This feed-name s used as an indicator to group set of domain-names and map them to a tenant (profile, template, term, or IP address).
When the DNS packets are received from a particular SRC IP address, the corresponding feed-name is fetched and lookup happens against the domain-names mapped with the feed-name associated with the term. If the feed-name is not provisioned for that IP address, then it falls back to the feed-name configured at the template-level and lookup happens against the domain-names mapped with the feed-name associated with the template. If the feed-name is not configured at template, then the lookup is against the domain-names mapped against the feed-name associated with the profile.
Configuring Multi-tenant Support for DNS Filtering
Example: Configuring Multitenant Support for DNS Filtering
Configuration
CLI Quick Configuration
To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level.
set services service-set Test Zone3 syslog mode stream set services service-set Test Zone3 syslog source-address 10.1.1.1 set services service-set Test Zone3 syslog stream t1 category urlf set services service-set Test Zone3 syslog stream t1 host 10.10.1.1 set services service-set Test Zone3 syslog stream t1 routing-instance client_vr4 set services service-set Test Zone3 web-filter-profile Test-Profile-3-Zone3 set services service-set Test Zone3 next-hop-service inside-service-interface ams3.24 set services service-set Test Zone3 next-hop-service outside-service-interface ams3.25 set services web-filter multi-tenant-support set services web-filter multi-tenant-hash file-hash-key ascii-text "$9$VjsgJikP36AGD6Ap0hcbs2" set services web-filter multi-tenant-hash hash-method hmac-sha2-256 set services web-filter profile Test-Profile-3-Zone3 feed-name abc set services web-filter profile Test-Profile-3-Zone3 global-dns-filter-stats-log-timer 20 set services web-filter profile Test-Profile-3-Zone3 dns-filter statistics-log-timer 5 set services web-filter profile Test-Profile-3-Zone3 dns-filter dns-resp-ttl 100 set services web-filter profile Test-Profile-3-Zone3 dns-filter wildcarding-level 10 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area1 inactive: client-interfaces xe-7/0/2.32 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area1 inactive: server-interfaces xe-7/2/0.36 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area1 inactive: client-routing-instance client_vr4 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area1 inactive: server-routing-instance server_vr4 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area1 term Test-Profile-3-Zone3-Area1-Customer1 feed-name customer2 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area1 term Test-Profile-3-Zone3-Area1-Customer1 from src-ip-prefix 10.12.1.1 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area1 term Test-Profile-3-Zone3-Area1-Customer1 then dns-sinkhole set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area1 term Test-Profile-3-Zone3-Area1-Customer2 feed-name customer2 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area1 term Test-Profile-3-Zone3-Area1-Customer2 from src-ip-prefix 2001:db8::0/96 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area1 term Test-Profile-3-Zone3-Area1-Customer2 then dns-sinkhole set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area1 term Test-Profile-3-Zone3-Area1-Customer3 from src-ip-prefix 2001:db8:bbbb::/96 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area1 term Test-Profile-3-Zone3-Area1-Customer3 then dns-sinkhole set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area2 inactive: client-interfaces xe-7/0/2.32 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area2 inactive: server-interfaces xe-7/2/0.36 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area2 inactive: client-routing-instance client_vr4 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area2 inactive: server-routing-instance server_vr4 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area2 term Test-Profile-3-Zone3-Area2-Customer1 from src-ip-prefix 22.21.128.0/17 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone3-Area2 term Test-Profile-3-Zone3-Area2-Customer1 then dns-sinkhole set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone4-Area2 feed-name customer2 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone4-Area2 inactive: client-routing-instance client_vr4 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone4-Area2 inactive: server-routing-instance server_vr4 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone4-Area2 term Test-Profile-3-Zone4-Area2-Customer1 from src-ip-prefix 2001:0db8:0001:/48 set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone4-Area2 term Test-Profile-3-Zone4-Area2-Customer1 then dns-sinkhole set services web-filter profile Test-Profile-3-Zone3 dns-filter-template Test-Profile-3-Zone4-Area2 term wildcard then dns-sinkhole set interfaces xe-7/0/0 unit 0 family inet address 10.11.1.1/24 set interfaces xe-7/0/1 unit 0 family inet address 10.12.1.1/24 set interfaces xe-7/0/2 flexible-vlan-tagging set interfaces xe-7/0/2 mtu 9192 set interfaces xe-7/0/2 encapsulation flexible-ethernet-services set interfaces xe-7/0/2 unit 1 vlan-id 10 set interfaces xe-7/0/2 unit 1 family inet address 198.31.100.1/24 set interfaces xe-7/0/2 unit 31 vlan-id 31 set interfaces xe-7/0/2 unit 31 family inet address 198.51.70.1/24; set interfaces xe-7/0/2 unit 31 family inet6 address 2001:db8:10::0/96 set interfaces xe-7/0/2 unit 32 vlan-id 32 set interfaces xe-7/0/2 unit 32 family inet address 198.51.71.1/24; set interfaces xe-7/0/2 unit 32 family inet6 address 2001:db8:11::0/96 set interfaces xe-7/0/2 unit 33 vlan-id 33 set interfaces xe-7/0/2 unit 33 family inet address 198.51.72.1/24 set interfaces xe-7/0/2 unit 33 family inet6 address 2001:db8:12::0/96 set interfaces xe-7/0/2 unit 34 vlan-id 34 set interfaces xe-7/0/2 unit 34 family inet address 198.51.73.1/24 set interfaces xe-7/0/2 unit 34 family inet6 address 2001:db8:13::0/96 set interfaces xe-7/0/2 unit 35 vlan-id 35 set interfaces xe-7/0/2 unit 35 vlan-id 35 family inet address 198.51.74.1/24 set interfaces xe-7/0/2 unit 3135 vlan-id 35 family inet6 address 2001:db8:14::0/96 set interfaces xe-7/0/2 unit 36 vlan-id 36 set interfaces xe-7/0/2 unit 36 family inet address 198.51.75.1/24 set interfaces xe-7/0/2 unit 36 family inet6 address 2001:db8:15::0/96 set interfaces xe-7/0/2 unit 37 vlan-id 37 set interfaces xe-7/0/2 unit 37 family inet address 198.51.76.1/24 set interfaces xe-7/0/2 unit 37 family inet6 address 2001:db8:16::0/96 set interfaces xe-7/0/2 unit 38 vlan-id 38 set interfaces xe-7/0/2 unit 38 family inet address 198.51.77.1/24 set interfaces xe-7/0/2 unit 38 family inet6 address 2001:db8:17::0/96 set interfaces xe-7/0/2 unit 39 vlan-id 39 set interfaces xe-7/0/2 unit 39 family inet address 198.51.78.1/24 set interfaces xe-7/0/2 unit 39 family inet6 address 2001:db8:18::0/96 set interfaces xe-7/0/2 unit 40 vlan-id 40 set interfaces xe-7/0/2 unit 40 family inet address 198.51.79.1/24 set interfaces xe-7/0/2 unit 40 family inet6 address 2001:db8:19::0/96 set interfaces xe-7/0/2 unit 41 vlan-id 41 set interfaces xe-7/0/2 unit 41 family inet address 198.51.80.1/24 set interfaces xe-7/0/2 unit 41 family inet6 address 2001:db8:20::0/96 set interfaces xe-7/2/0 flexible-vlan-tagging set interfaces xe-7/2/0 mtu 1514 set interfaces xe-7/2/0 encapsulation flexible-ethernet-services set interfaces xe-7/2/0 inactive unit 1 vlan-id 1 set interfaces xe-7/2/0 inactive unit 1 family inet address 198.168.50.0/24 set interfaces xe-7/2/0 inactive unit 1 family inet6 address 2001:0db0:1600:0::1/112 set interfaces xe-7/2/0 unit 2 vlan-id 2 set interfaces xe-7/2/0 unit 2 vlan-id 2 family inet address 198.100.70.0/24 set interfaces xe-7/2/0 unit 31 vlan-id 31 set interfaces xe-7/2/0 unit 31 family inet address 10.1.0.1/16 set interfaces xe-7/2/0 unit 31 family inet6 address 2001:0db0:1601:0::1/112 set interfaces xe-7/2/0 unit 32 vlan-id 32 set interfaces xe-7/2/0 unit 32 family inet address 10.2.0.1/16 set interfaces xe-7/2/0 unit 32 family inet6 address 2001:0db0:1602:0::1/112 set interfaces xe-7/2/0 unit 33 vlan-id 33 set interfaces xe-7/2/0 unit 33 family inet address 10.3.0.1/16 set interfaces xe-7/2/0unit 33 vlan-id 33 family inet6 address 2001:0db0:1603:0::1/112 set interfaces xe-7/2/0 unit 34 vlan-id 34 set interfaces xe-7/2/0 unit 34 family inet address 10.0.0.1/16 set interfaces xe-7/2/0 unit 34 family inet6 address 2001:0db0:1600:0::1/112 set interfaces xe-7/2/0 unit 35 vlan-id 35 set interfaces xe-7/2/0 unit 35 family inet address 10.4.0.1/16 set interfaces xe-7/2/0 unit 35 family inet6 address 2001:0db0:1604:0::1/112 set interfaces xe-7/2/0 unit 36 vlan-id 36 set interfaces xe-7/2/0 unit 36 family inet address 10.5.0.1/16 set interfaces xe-7/2/0 unit 36 family inet6 address 2001:0db0:1605:0::1/112 set interfaces xe-7/2/0 unit 37 vlan-id 37 set interfaces xe-7/2/0 unit 37 family inet address 10.6.0.1/16 set interfaces xe-7/2/0unit 37 family inet6 address 2001:0db0:1606:0::1/112 set interfaces xe-7/2/0 unit 38 vlan-id 38 set interfaces xe-7/2/0 unit 38 family inet address 10.7.0.1/16 set interfaces xe-7/2/0 unit 38 vlan-id 38 family inet6 address 2001:0db0:160:0::1/112 set interfaces ams3 load-balancing-options member-interface mams-3/0/0 set interfaces ams3 load-balancing-options member-interface mams-3/1/0 set interfaces ams3 load-balancing-options member-failure-options redistribute-all-traffic enable-rejoin set interfaces ams3 load-balancing-options high-availability-options many-to-one preferred-backup mams-3/1/0 set interfaces ams3 unit 22 family inet set interfaces ams3 unit 22 family inet6 set interfaces ams3 unit 22 service-domain inside set interfaces ams3 unit 22 load-balancing-options hash-keys ingress-key (source-ip destination-ip ) set interfaces ams3 unit 24 family inet set interfaces ams3 unit 24 family inet6 set interfaces ams3 unit 24 service-domain inside set interfaces ams3 unit 24 family inet6 load-balancing-options hash-keys ingress-key (source-ip destination-ip) set interfaces ams3 unit 25 family inet set interfaces ams3 unit 25 family inet6 set interfaces ams3 unit 25 service-domain inside set interfaces ams3 unit 25 load-balancing-options hash-keys ingress-key (source-ip destination-ip ) set routing-instances client_vr4 instance-type virtual-router set routing-instances client_vr4 routing-options rib client_vr4.inet6.0 static route 2001:0db0:bbbb:0::0/49 next-hop 2001:0db0:7070:71::2 set routing-instances client_vr4 routing-options rib client_vr4.inet6.0 static route 2001:0db0:aaaa:8000::0/49 next-hop 2001:0db0:7070:71::3 set routing-instances client_vr4 routing-options rib client_vr4.inet6.0 static route 60::0/64 next-hop ams3.24 set routing-instances client_vr4 routing-options static route 10.12.1.1 next-hop 192.168.1.2 set routing-instances client_vr4 routing-options static route 22.21.128.0/17 next-hop 192.168.1.3 set routing-instances client_vr4 routing-options static route 0.0.0.0/0 next-hop ams3.24 set routing-instances client_vr4 routing-options static route 10.11.10.10/16 next-hop 192.168.1.4 set routing-instances client_vr4 routing-options static route 10.10.23.10/16 next-hop 192.168.1.5 set routing-instances client_vr4 routing-options static route 10.1.0.0/16 next-hop 192.168.1.6 set routing-instances client_vr4 routing-options static route 10.20.20.0/16 next-hop 192.168.1.7 set routing-instances client_vr4 routing-options static route 10.2.0.0/16 next-hop 192.168.1.8 set routing-instances client_vr4 routing-options static route 10.30.20.0/16 next-hop 192.168.1.9 set routing-instances client_vr4 routing-options static route 10.3.0.0/16 next-hop 192.168.10. set routing-instances client_vr4 routing-options static route 10.40.20.0/16 next-hop 192.168.1.11 set routing-instances client_vr4 routing-options static route 10.4.0.0/16 next-hop 192.168.1.12 set routing-instances client_vr4 routing-options static route 10.50.20.0/16 next-hop 192.168.1.13 set routing-instances client_vr4 interface xe-7/0/0.0 set routing-instances client_vr4 interface xe-7/0/2.32 set routing-instances client_vr4 interface ams3.24 set routing-instances server_vr4 instance-type virtual-router set routing-instances server_vr4 routing-options rib server_vr4.inet6.0 static route 2001:0db0:2221:0::0/48 next-hop ams3.25 set routing-instances server_vr4 routing-options rib server_vr4.inet6.0 static route 2001:db8:ffff::1/128 next-hop 2001:0db0:1605:0::2 set routing-instances server_vr4 routing-options rib server_vr4.inet6.0 static route 2001:db8:bbbb::1/128 next-hop 2001:0db0:1605:0::3 set routing-instances server_vr4 routing-options static route 10.10.20.1 next-hop ams3.25 set routing-instances server_vr4 routing-options static route 60.0.6.0/24 next-hop 192.0.2.2 set routing-instances server_vr4 routing-options static route 60.0.18.0/24 next-hop 192.0.2.3 set routing-instances server_vr4 routing-options static route 10.9.9.0/24 next-hop ams3.25 set routing-instances server_vr4 routing-options static route 60.0.19.0/24 next-hop 192.0.2.4 set routing-instances server_vr4 routing-options static route 60.0.20.0/24 next-hop 192.0.2.5 set routing-instances server_vr4 routing-options static route 60.0.21.0/24 next-hop 192.0.2.6 set routing-instances server_vr4 routing-options static route 60.0.22.0/24 next-hop 192.0.2.7 set routing-instances server_vr4 routing-options static route 60.0.23.0/24 next-hop 192.0.2.8 set routing-instances server_vr4 routing-options static route 60.0.24.0/24 next-hop 192.0.2.9 set routing-instances server_vr4 routing-options static route 60.0.25.0/24 next-hop 192.0.2.10 set routing-instances server_vr4 routing-options static route 60.0.26.0/24 next-hop 192.0.2.11 set routing-instances server_vr4 routing-options static route 60.0.27.0/24 next-hop 192.0.2.12 set routing-instances server_vr4 routing-options static route 60.0.28.0/24 next-hop 192.0.2.13 set routing-instances server_vr4 routing-options static route 10.1.0.0/16 next-hop ams3.25 set routing-instances server_vr4 interface xe-7/0/1.0 set routing-instances server_vr4 interface xe-7/2/0.36 set routing-instances server_vr4 interface ams3.25 set routing-options static route 0.0.0.0/0 next-hop 10.48.179.254
Change History Table
Feature support is determined by the platform and release you are using. Use Feature Explorer to determine if a feature is supported on your platform.