Debian

DNSCrypt 似乎沒有加密查詢

  • October 26, 2020

我正在嘗試使用 Unbound 和 DNSCrypt 在 Raspberry 上設置 DNS 記憶體伺服器。

Raspberry 執行最新的 Jessie Lite(無頭 Debian 8)。

我使用這個流行的腳本設置 DNSCrypt:https://github.com/simonclausen/dnscrypt-autoinstall

Unbound 和 DNSCrypt 都執行良好:我的主電腦 (192.168.1.64) 成功使用了 Raspberry (192.168.1.65) 上的 DNS 伺服器,我可以通過日誌文件看到 Unbound using DNSCrypt。

我的問題是,當我訪問網站並通過僅返回標準查詢dig進行擷取時,我看不到任何加密。Wireshark

我錯過了什麼?

這是dig回應:

$ dig  debug.opendns.com  txt

; <<>> DiG 9.9.5-9+deb8u8-Raspbian <<>> debug.opendns.com txt
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 17686
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; ENDS: version: 0, flags:; upd: 4096
;; QUESTION SECTION:
;debug.opendns.com.             IN      TXT

;; AUTHORITY SECTION:
opendns.com.            2560    IN      SOA     auth1.opendns.com. noc.opendns.com. 1483610050 16384 2048 1048576 2560

;; Query time: 143 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Thu Jan 05 11:02:24 CET 2017
;; MSG SIZE  rcvd: 92

這是擷取的螢幕截圖Wireshark

在此處輸入圖像描述

這是 Unbound 的日誌:

[1483616499] unbound[5098:0] debug: module config: "iterator"
[1483616499] unbound[5098:0] notice: init module 0: iterator
[1483616499] unbound[5098:0] debug: target fetch policy for level 0 is 3
[1483616499] unbound[5098:0] debug: target fetch policy for level 1 is 2
[1483616499] unbound[5098:0] debug: target fetch policy for level 2 is 1
[1483616499] unbound[5098:0] debug: target fetch policy for level 3 is 0
[1483616499] unbound[5098:0] debug: target fetch policy for level 4 is 0
[1483616499] unbound[5098:0] debug: Forward zone server list:
[1483616499] unbound[5098:0] info: DelegationPoint<.>: 0 names (0 missing), 1 addrs (0 result, 1 avail) parentNS
[1483616499] unbound[5098:0] debug: cache memory msg=33040 rrset=33040 infra=1304 val=0
[1483616499] unbound[5098:0] info: start of service (unbound 1.4.22).
[1483616505] unbound[5098:0] debug: iterator[module 0] operate: extstate:module_state_initial event:module_event_new
[1483616505] unbound[5098:0] info: resolving www.google.com. A IN
[1483616505] unbound[5098:0] info: processQueryTargets: www.google.com. A IN
[1483616505] unbound[5098:0] info: sending query: www.google.com. A IN
[1483616505] unbound[5098:0] debug: sending to target: <.> 127.0.0.1#40
[1483616505] unbound[5098:0] debug: cache memory msg=33040 rrset=33040 infra=1533 val=0
[1483616505] unbound[5098:0] debug: iterator[module 0] operate: extstate:module_wait_reply event:module_event_reply
[1483616505] unbound[5098:0] info: iterator operate: query www.google.com. A IN
[1483616505] unbound[5098:0] info: response for www.google.com. A IN
[1483616505] unbound[5098:0] info: reply from <.> 127.0.0.1#40
[1483616505] unbound[5098:0] info: query response was ANSWER
[1483616505] unbound[5098:0] info: finishing processing for www.google.com. A IN

這是Unbound的配置文件:

server:
       auto-trust-anchor-file: "/var/lib/unbound/root.key"

server:
       username: unbound
       port: 53
       logfile: "/var/log/unbound/unbound.log"
       log-time-ascii: no
       use-syslog: no
       verbosity: 3
       module-config: "iterator"
       do-not-query-localhost: no
       interface: 0.0.0.0
       access-control: 127.0.0.1 allow
       access-control: 192.168.1.0/24 allow
       access-control: 10.8.0.0/24 allow

forward-zone:
       name: "."
       forward-addr: 127.0.0.1@40
       forward-first: no

remote-control:
       control-enable: no

這是腳本生成的 DNSCrypt 的配置:

DNSCRYPT_LOCALIP=127.0.0.1
DNSCRYPT_LOCALPORT=40
DNSCRYPT_USER=dnscrypt
DNSCRYPT_RESOLVER=ns0.dnscrypt.is

Wireshark 擷取顯示源和目標都是本地 IP 地址。

因此,這只是記錄您的電腦和 Raspberry Pi 之間的流量。這是正常的 DNS 流量。加密流量在 Raspberry Pi 和ns0.dnscrypt.is解析器之間,即進入 Internet 的流量。

這是您應該進行數據包擷取的地方。

或者,如果您想要驗證您的電腦和 Raspberry Pi 之間的流量,則客戶端代理需要在您的電腦上執行,而在 Raspberry Pi 上,您需要執行 DNSCrypt 伺服器(dnscrypt-wrapper 或 dnsdist)。

引用自:https://unix.stackexchange.com/questions/335046