DNSCrypt offers a way to protect clients against attacks related to the modification and manipulation of DNS traffic — The main objective of DNSCrypt is authentication of the communication channel between the client (you) and a resolver supporting the protocol — This will protect the client from man in the middle attacks. In addition, encryption of DNS communication improves the client's privacy. DNSCrypt is the client-side version of dnscrypt-wrapper.
DNSCrypt verifies that responses you get from a DNS provider have been actually sent by that provider, and haven't been tampered with.
This is not a VPN. It doesn't mask your IP address, and if you are using it with a public DNS service, be aware that it will (and has to) decrypt your queries.
If you are using it for privacy, it might do the opposite of what you are trying to achieve. If you are using it to prevent VPN "leaks", this isn't the right tool either: the proper way to prevent VPN "leaks" is to avoid sending data to yet another third party: use a VPN service that operates its own DNS resolvers.
dnscrypt-proxy and libsodium is in the official repository for Chaos Calmer 15.05 and up.
opkg update opkg install dnscrypt-proxy
The OpenWrt package for ar71xx is maintained by black-roland.
Differences with OpenWrt packages:
| ||Newest version for Chaos Calmer (with ephemeral keys support). Barrier Breaker support. Procd support and possibility of launching multiple instances.|
| ||Newest version for Chaos Calmer. Barrier Breaker support.|
This will install
dnscrypt-proxy as well as any dependent libraries such as
Add third-party source to your opkg configuration file
/etc/opkg.conf according to your OpenWrt version.
cd /tmp uclient-fetch 'http://exopenwrt.roland.black/exopenwrt.pub' opkg-key add exopenwrt.pub echo '/etc/opkg/keys/1a929a1dd62138c1' >> /etc/sysupgrade.conf echo 'src/gz exopenwrt http://exopenwrt.roland.black/snapshots/trunk/ar71xx/packages/exopenwrt' >> /etc/opkg/customfeeds.conf
cd /tmp wget 'http://exopenwrt.roland.black/exopenwrt.pub' opkg-key add exopenwrt.pub echo '/etc/opkg/keys/1a929a1dd62138c1' >> /etc/sysupgrade.conf echo 'src/gz exopenwrt http://exopenwrt.roland.black/chaos_calmer/15.05.1/ar71xx/packages/exopenwrt' >> /etc/opkg.conf
And proceed with the installation itself:
opkg update opkg install dnscrypt-proxy
DNSCrypt is listening on address and port:
127.0.0.1:5353. We need to set OpenWrt to send DNS request to that address.
The config file
/etc/config/dnscrypt-proxy is simple and should be edited according to your needs. Possible values for the 'resolver' option are the first column in the list of public DNSCrypt resolvers.
| ||string||yes|| ||The IP address of the proxy server.|
| ||string||yes|| ||Listening port for DNS queries.|
| ||string||no|| ||DNS service for resolving queries. You can't add more than one resolver.|
| ||string||no|| || Location of CSV file containing list of resolvers. When you use a custom DNSCrypt server and you later get problems when executing DNSCrypt, have a look in the resolver list (
| ||boolean||no|| ||Improve privacy by using an ephemeral public key for each query. Note that you cannot yet use it with current versions of OpenWrt as the dnscrypt-proxy package is outdated and uses a version of DNSCrypt, which does not support ephemeral keys. Ephemeral keys option requires extra CPU cycles (especially on non-x86 platforms) and can cause huge system load. Disable it in case of performance problems. Also this option is useless with most DNSCrypt servers (all the servers using short TTLs for the certificates, which is done by default in the Docker image).|
If you need to specify other options, you will have to edit the
Note: I've had a little bit of confusion at setup, so I want to remind you; address and port strings are for local proxy server, you just have to pick a DNSCrypt server from the resolvers list, put its name in resolver string and comment out resolvers and resolvers list settings.
Now we will start DNSCrypt and enable auto boot for it:
/etc/init.d/dnscrypt-proxy enable /etc/init.d/dnscrypt-proxy start
Note: If dnscrypt-proxy is not starting after a router reboot, it may be trying to start before the network interface is fully up. Add the following to
/etc/rc.local, above the line "exit 0":
sleep 10 /etc/init.d/dnscrypt-proxy start
Assuming you are using
dnsmasq, edit the bold lines in
/tmp/resolv.conf.autofile since it instruct
dnsmasqto use your ISP's DNS.
noresolvoption also disables
/etc/resolv.conffile for similar reason.
127.0.0.1#5353is the DNSCrypt address.
/pool.ntp.org/188.8.131.52adds an exception for pool.ntp.org, which will be resolved through the standard unencrypted DNS channel. DNSCrypt requires precise time, otherwise it will not resolve any domain, including pool.ntp.org. So if your device's time was incorrect, it could never update its time, and therefore DNSCrypt would never work. So we set this exception so that pool.ntp.org queries will always bypass DNSCrypt and resolve with the standard unencrypted OpenDNS method.
Reboot router or restart
dnsmasq for the changes to take effect.
Note: you may need admin privileges to run the commands below.
sudo /etc/init.d/nscd restart
sudo /etc/init.d/networking restart
On the router:
pkill -STOP dnscrypt-proxy
DNS resolution should not work any more.
To restore service, unfreeze the client proxy:
pkill -CONT dnscrypt-proxy
The easy way is to look in the log.
dnsmasqis using only dnscrypt. Only the last block of logged nameservers is relevant.
logread | grep -n "using nameserver"
132:Jan 1 01:01:00 openwrt daemon.info dnsmasq: using nameserver 184.108.40.206#53 for domain pool.ntp.org 133:Jan 1 01:01:00 openwrt daemon.info dnsmasq: using nameserver 127.0.0.1#5353
logread | grep "Proxying from"
Jul 1 12:00:00 openwrt daemon.info dnscrypt-proxy: Proxying from 127.0.0.1:5353 to 220.127.116.11:443
A "suspicious" certificate can be reported:
Check the date and time on your router: this kind of behavior is usually caused by a system clock that hasn't been set properly.