Stubby is an application that acts as a local DNS Privacy stub resolver (using DNS-over-TLS). Stubby encrypts DNS queries sent from a client machine (desktop or laptop) to a DNS Privacy resolver increasing end user privacy. Stubby is in the early stages of development but is suitable for technical/advanced users. A more generally user-friendly version is on the way!
Stubby provides DNS Privacy by:
Stubby is developed by the getdns team.
Stubby can be used as a command line tool requiring the user to manually modify the system DNS resolvers. A development version of a Stubby Manager GUI is also available for Windows, see Stubby Mananger GUI.
See Stubby Homepage for more details
Stubby uses getdns and requires the 1.5.0 release of getdns or later.
It also requires yaml.
Check to see if stubby, getdns and yaml are available via a package manager for your system: https://repology.org/metapackage/stubby/versions https://repology.org/metapackage/getdns/versions https://repology.org/metapackage/libyaml/versions
brew install stubby
).If you need to install getdns from source, see the section at the end of this document.
A Dockerfile is provided in the contrib directory to build a Docker image from source. See Docker usage docs.
Get the code:
git clone https://github.com/getdnsapi/stubby.git
Build and install (NOTE: from release 0.3.0 stubby uses cmake)
cd stubby
cmake .
make
If you get an error Could NOT find Getdns (missing: GETDNS_LIBRARIES GETDNS_INCLUDE_DIR)
then you need to set the following 2 variable as arguements to cmake
:
cmake -DGETDNS_LIBRARY=<path to libgetdns> -DGETDNS_INCLUDE_DIR=<path to getdns.h header file> .
A quick start guide to using cmake
with getdns is here.
It is recommended to use the default configuration file provided which will use 'Strict' privacy mode and spread the DNS queries among several of the current DNS Privacy test servers. Note that this file contains both IPv4 and IPv6 addresses. This file is installed on *nix systems as /usr/local/etc/stubby/stubby.yml
The configuration file format is a YAML like format and the name of the file must have an extension of .yml. Essentially the
configuration options available are the same as the options that can be set on a getdns context
- Doxygen documentation for
which is available here. To aid with creating a custom configuration file, an example is given below.
NOTE: As of the 0.1.3 release of Stubby the YAML format replaces the JSON like format used in earlier versions of the configuration file for getdns/stubby. The YAML format is
more human readable and supports comments allowing options to be easily enabled and disabled. The JSON format is that which is used internally in getdns
(it is the same as the output returned by stubby -i
) and is still available by directly specifying a file with the name 'stubby.conf' on the command line using the -C option.
Alternatively the configuration file location can be specified on the command line using the -C
flag. Changes to the configuration file require a restart of Stubby.
The config file below will configure Stubby in the following ways:
resolution_type
: Work in stub mode only (not recursive mode) - required for Stubby operation.dns_transport_list
: Use TLS only as a transport (no fallback to UDP or TCP). tls_authentication
: Use Strict Privacy i.e. require a TLS connection and authentication of the upstream
tls_authentication: GETDNS_AUTHENTICATION_REQUIRED
field. In Opportunistic mode authentication of the nameserver is not required and fallback to clear text transports is permitted if they are in the dns_transport_list
.tls_query_padding_blocksize
: Use the EDNS0 padding option to pad DNS queries to hide their sizeedns_client_subnet_private
: Use EDNS0 Client Subnet privacy so the client subnet is not sent to authoritative serversidle_timeout
: Use an EDNS0 Keepalive idle timeout of 10s unless overridden by the server. This keeps idle TLS connections open to avoid the overhead of opening a new connection for every query.listen_address
: have the Stubby daemon listen on IPv4 and IPv6 on port 53 on the loopback addressround_robin_upstreams
: Round robin queries across all the configured upstream servers. Without this option Stubby will use each upstream server sequentially until it becomes unavailable and then move on to use the next. upstream_recursive_servers
: Use the NLnet labs test DNS Privacy Server for outgoing queries. In Strict Privacy mode, at least one of the following is required for each nameserver:
tls_auth_name
: This is the authentication domain name that will be verified against the presented certificate. tls_pubkey_pinset
: The sha256 SPKI pinset for the server. This is also verified against the presented certificate. resolution_type: GETDNS_RESOLUTION_STUB
dns_transport_list:
- GETDNS_TRANSPORT_TLS
tls_authentication: GETDNS_AUTHENTICATION_REQUIRED
tls_query_padding_blocksize: 256
edns_client_subnet_private : 1
idle_timeout: 10000
listen_addresses:
- 127.0.0.1
- 0::1
round_robin_upstreams: 1
upstream_recursive_servers:
- address_data: 185.49.141.38
tls_auth_name: "getdnsapi.net"
tls_pubkey_pinset:
digest: "sha256"
value: foxZRnIh9gZpWnl+zEiKa0EJ2rdCGroMWm02gaxSc9Q=
Additional privacy servers can be specified by adding more entries to the upstream_recursive_servers
list above (note a separate entry must be made for the IPv4 and IPv6 addresses of a given server. More DNS Privacy test servers are listed here.
A custom port can be specified by adding the tls_port:
attribute to the upstream_recursive_server
in the config file.
More details can be found in the comments in the default configuration file and at https://dnsprivacy.org/wiki/display/DP/Configuring+Stubby
Simply invoke Stubby on the command line. By default it runs in the foreground, the -g
flag runs it in the background.
> sudo stubby
Or, to let it run as an unprivileged user:
> sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/stubby
> stubby
-l
flag. The logging is currently simplistic and simply writes to stdout. (We are working on making this better!)The Windows and macOS installers include scripts to run stubby as a managed daemon. We have basic support for using systemd to manage Stubby, see systemd
A quick test can be done by using dig (or your favourite DNS tool) on the loopback address
> dig @127.0.0.1 www.example.com
> getdns_query -s @127.0.0.1 www.example.com
!!! Once this change is made your DNS queries will be re-directed to Stubby and sent over TLS!
(You may need to restart some applications to have them pick up the network settings).
You can monitor the traffic using Wireshark watching on port 853.
For Stubby to re-send outgoing DNS queries over TLS the system stub resolvers on your machine must be changed to send all the local queries to the loopback interface on which Stubby is listening. This depends on the operating system being run. It is useful to note your existing default nameservers before making this change!
nameserver 127.0.0.1
nameserver ::1
A script is provided with Stubby for easier configuration. From the command line you can do the following to switch all your queries to use Stubby
> sudo /usr/local/sbin/stubby-setdns-macos.sh
If you want to reset, just use:
> sudo /usr/local/sbin/stubby-setdns-macos.sh -r
which should pick up the default DHCP nameservers.
You can add /usr/local/sbin to your path to avoid having to type it above by doing
export PATH=/usr/local/sbin:$PATH
Or via the macOs System Settings GUI:
127.0.0.1
and ::1
(only add the IPv4 address if you don't have IPv6)See the file windows/README.txt for a detailed description of building and using Stubby on windows.
Powershell scripts are provided in the the windows directory of the source code that can be used to update the system resolvers. Instructions for how to update the resolvers manually are provided are also provided - see https://dnsprivacy.org/wiki/display/DP/Windows+installer+for+Stubby Stubby has been reported to work on Windows 7, but we don't officially support it.
Note that from getdns 1.1.3 stubby is included in the getdns code as a git submodule. Therefore stubby and getdns can be built together by following the
instructions in the getdns README and setting the BUILD_STUBBY
option.
--enable-debug-stub
If you do want to see very detailed debug information as messages are processed then add the--enable-debug-stub
option to theconfigure
line above (not recommended for use with Stubby)
The contrib directory contains code kindly contributed by various people:
vapniks Tom Matthews CameronNemo