pfsense:dns:force_dns_over_tls
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
pfsense:dns:force_dns_over_tls [2021/01/04 19:38] – created peter | pfsense:dns:force_dns_over_tls [2022/10/08 09:13] (current) – [Another Example] peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PFSense - DNS - Force DNS over TLS ====== | ====== PFSense - DNS - Force DNS over TLS ====== | ||
+ | |||
+ | DNS requests are normally not encrypted, and therefore visible to your ISP to record, use for research / marketing purposes, or even (in the case of some nefarious actors) manipulate or change. | ||
+ | |||
+ | Running DNS over TLS prevents that, by encrypting your DNS traffic so that it cannot be manipulated or collected. | ||
+ | |||
+ | <WRAP important> | ||
+ | **WARNING: | ||
+ | |||
+ | However this is only for the first query. | ||
+ | |||
+ | Reason for this is that TLS takes longer. | ||
+ | |||
+ | To prevent this increase in latency, switch to standard port 53. | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | Navigate to **Services -> DNS Resolver**. | ||
+ | |||
+ | Add the following to the **Custom Options**. | ||
+ | |||
+ | <code bash> | ||
+ | server: | ||
+ | access-control-view: | ||
+ | access-control-view: | ||
+ | access-control-view: | ||
+ | access-control-view: | ||
+ | view: | ||
+ | name: " | ||
+ | view-first: yes | ||
+ | view: | ||
+ | name: " | ||
+ | view-first: yes | ||
+ | include: / | ||
+ | view: | ||
+ | name: " | ||
+ | view-first: yes | ||
+ | forward-addr: | ||
+ | forward-addr: | ||
+ | view: | ||
+ | name: " | ||
+ | view-first: yes | ||
+ | tls-cert-bundle: | ||
+ | forward-tls-upstream: | ||
+ | forward-addr: | ||
+ | forward-addr: | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | * to specify **tls-cert-bundle** option that points to the local system' | ||
+ | * allow unbound to forward TLS requests; **forward-tls-upstream: | ||
+ | * specify any number of servers that allow DNS over TLS. | ||
+ | |||
+ | For each server you will need to specify that the connection port using **@**, and you will also need to indicate which is its domain name with **#**. | ||
+ | |||
+ | * Even though it looks like an comment the hashtag name allows for the TLS authentication name to be set for stub-zones and with unbound-control forward control command. | ||
+ | * There should not be any spaces between the @ and # markups. | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Another Example ===== | ||
+ | |||
+ | Navigate to **Services -> DNS Resolver** | ||
+ | |||
+ | * DNS Query Forwarding: | ||
+ | * Custom Options: | ||
+ | server: | ||
+ | # Next line is needed only if pfBlockerNG is being used. | ||
+ | include: / | ||
+ | ssl-upstream: | ||
+ | do-tcp: yes | ||
+ | forward-zone: | ||
+ | name: " | ||
+ | # Below 4 addresses are Cloudflare DNS. | ||
+ | forward-addr: | ||
+ | forward-addr: | ||
+ | forward-addr: | ||
+ | forward-addr: | ||
+ | # Below 3 addresses are Quad9 DNS. | ||
+ | forward-addr: | ||
+ | forward-addr: | ||
+ | forward-addr: | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | It is OK to set the resolver to listen on all interfaces, since the firewall rules on the WAN will prevent Internet hosts from using your resolver anyway. | ||
+ | |||
+ | </ | ||
+ | |||
+ | <WRAP important> | ||
+ | **WARNING: | ||
+ | |||
+ | However this is only for the first query. | ||
+ | |||
+ | Reason for this is that CloudFlare' | ||
+ | |||
+ | To prevent this increase in latency, switch to standard port 53, or to an alternative DNS provider that does not use TLS for example: | ||
+ | |||
+ | < | ||
+ | server: | ||
+ | # | ||
+ | #do-tcp: yes | ||
+ | forward-zone: | ||
+ | name: " | ||
+ | # Below 4 addresses are Cloudflare DNS SSL. | ||
+ | # forward-addr: | ||
+ | # forward-addr: | ||
+ | # forward-addr: | ||
+ | # forward-addr: | ||
+ | # Non TLS. | ||
+ | forward-addr: | ||
+ | forward-addr: | ||
+ | forward-addr: | ||
+ | forward-addr: | ||
+ | </ | ||
+ | |||
+ | Try other settings as needed, for instance: | ||
+ | |||
+ | < | ||
+ | server: | ||
+ | do-tcp: yes | ||
+ | # Speed and privacy | ||
+ | minimal-responses: | ||
+ | prefetch: yes | ||
+ | qname-minimisation: | ||
+ | rrset-roundrobin: | ||
+ | forward-zone: | ||
+ | name: " | ||
+ | # To keep local overrides and avoid slow downs. | ||
+ | forward-ssl-upstream: | ||
+ | # Below addresses are Cloudflare DNS | ||
+ | forward-addr: | ||
+ | forward-addr: | ||
+ | # forward-addr: | ||
+ | # forward-addr: | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | So using **forward-tls-upstream** instead inside the ' | ||
+ | </ | ||
+ | |||
+ | |||
+ | Testing with Google Chrome was a bit upset at first, but a **< | ||
+ | |||
+ | Measured a few lookups with Chrome and the network inspector, and it looks like uncached lookups are taking about 50ms. Without TLS the lookups run about 10ms. | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Test ===== | ||
+ | |||
+ | ==== Test using an internal DNS: ==== | ||
+ | |||
+ | <code bash> | ||
+ | dig www.google.com @pfSense.localdomain | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | You can use use **Diagnostics -> Packet Capture**, and capture port 853 to verify that requests are being triggered. | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Test using an external DNS ==== | ||
+ | |||
+ | Try and dig something against an IP that you know is not internal and is not a DNS server. | ||
+ | |||
+ | <code bash> | ||
+ | dig www.google.com @8.8.8.8 | ||
+ | </ | ||
+ | |||
+ | Assuming that’s all fine, you should now be able to configure a broad block rule to bar all outbound port 53. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Block all outbound non-encrypted DNS ===== | ||
+ | |||
+ | Navigate to **Firewall -> Rules** | ||
+ | |||
+ | On the **WAN** interface, define a new rule at the top of the list. This rule should use these settings; | ||
+ | |||
+ | * Action: **Block**. | ||
+ | * Interface: **WAN**. | ||
+ | * Address Family: **IPv4+IPv6**. | ||
+ | * Protocol: **TCP/ | ||
+ | * Source: **any**. | ||
+ | * Destination: | ||
+ | * Destination Port: **DNS (53)**. | ||
+ | * Description: | ||
+ | |||
+ | Verify that you can still resolve against the local resolver (your router’s IP), and that you can still resolve against what seems to be external resolver (e.g, 8.8.8.8). | ||
+ | |||
+ | You should also check that when you do so that nothing passes on the WAN interface on port 53. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== References ===== | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
pfsense/dns/force_dns_over_tls.1609789107.txt.gz · Last modified: 2021/01/04 19:38 by peter