hickory-dns/README.md

270 lines
14 KiB
Markdown
Raw Normal View History

2015-11-16 04:57:59 +00:00
[![Build Status](https://travis-ci.org/bluejekyll/trust-dns.svg?branch=master)](https://travis-ci.org/bluejekyll/trust-dns)
[![Build status](https://ci.appveyor.com/api/projects/status/tmlih8wdt7628vyl/branch/master?svg=true)](https://ci.appveyor.com/project/bluejekyll/trust-dns/branch/master)
2017-10-27 08:21:04 +00:00
[![codecov](https://codecov.io/gh/bluejekyll/trust-dns/branch/master/graph/badge.svg)](https://codecov.io/gh/bluejekyll/trust-dns)
2016-08-18 20:17:29 +00:00
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE-MIT)
[![License: Apache 2.0](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](LICENSE-APACHE)
# trust-dns
2015-08-22 00:29:00 +00:00
A Rust based DNS client and server, built to be safe and secure from the
ground up.
2015-08-14 23:28:01 +00:00
This repo consists of multiple crates:
| Library | Status | Description |
|---------|--------|-------------|
2017-10-17 14:43:34 +00:00
| **Proto** | [![](http://meritbadge.herokuapp.com/trust-dns-proto)](https://crates.io/crates/trust-dns-proto) [![trust-dns-proto](https://docs.rs/trust-dns-proto/badge.svg)](https://docs.rs/trust-dns-proto) | Raw DNS library, exposes an unstable API and only for use by the other Trust-DNS libraries, not intended for end-user use. |
| **Client** | [![](http://meritbadge.herokuapp.com/trust-dns)](https://crates.io/crates/trust-dns) [![trust-dns](https://docs.rs/trust-dns/badge.svg)](https://docs.rs/trust-dns) | Used for sending `query`, `update`, and `notify` messages directly to a DNS server. |
| **Server** | [![](http://meritbadge.herokuapp.com/trust-dns-server)](https://crates.io/crates/trust-dns-server) [![trust-dns-server](https://docs.rs/trust-dns-server/badge.svg)](https://docs.rs/trust-dns-server) | Use to host DNS records, this also has a `named` binary for running in a daemon form. |
| **Resolver** | [![](http://meritbadge.herokuapp.com/trust-dns-resolver)](https://crates.io/crates/trust-dns-resolver) [![trust-dns-resolver](https://docs.rs/trust-dns-resolver/badge.svg)](https://docs.rs/trust-dns-resolver) | Utilizes the client library to perform DNS resolution. Can be used in place of the standard OS resolution facilities. |
| **Rustls** | [![](http://meritbadge.herokuapp.com/trust-dns-rustls)](https://crates.io/crates/trust_dns_rustls) [![trust-dns-rustls](https://docs.rs/trust-dns-rustls/badge.svg)](https://docs.rs/trust-dns-rustls) | Implementation of DNS over TLS protocol using the rustls and ring libraries. |
| **NativeTls** | [![](http://meritbadge.herokuapp.com/trust-dns-native-tls)](https://crates.io/crates/trust_dns_native_tls) [![trust-dns-native-tls](https://docs.rs/trust-dns-native-tls/badge.svg)](https://docs.rs/trust-dns-native-tls) | Implementation of DNS over TLS protocol using the Host OS' provided default TLS libraries |
| **OpenSsl** | [![](http://meritbadge.herokuapp.com/trust-dns-openssl)](https://crates.io/crates/trust_dns_openssl) [![trust-dns-openssl](https://docs.rs/trust-dns-openssl/badge.svg)](https://docs.rs/trust-dns-openssl) | Implementation of DNS over TLS protocol using OpenSSL |
2015-08-14 23:28:01 +00:00
# Goals
- Build a safe and secure DNS server and client with modern features.
2015-10-17 22:33:13 +00:00
- No panics, all code is guarded
2015-08-22 00:29:00 +00:00
- Use only safe Rust, and avoid all panics with proper Error handling
- Use only stable Rust
2015-08-14 23:28:01 +00:00
- Protect against DDOS attacks (to a degree)
2015-10-17 22:33:13 +00:00
- Support options for Global Load Balancing functions
- Make it dead simple to operate
2015-08-14 23:28:01 +00:00
# Status:
## Client
Using the ClientFuture is safe. ClientFuture is a brand new rewrite of the old
Client. It has all the same features as the old Client, but is written with the
wonderful futures-rs library. Please send feedback! It currently does not cache
2016-06-21 06:28:34 +00:00
responses, if this is a feature you'd like earlier rather than later, post a
request. The validation of DNSSec is complete including NSEC. As of now NSEC3
2016-06-02 06:24:25 +00:00
is broken, and I may never plan to support it. I have some alternative ideas
for private data in the zone. The old Client has been deprecated, so please
use the ClientFuture. If this is an inconvenience, I may add a convenience
wrapper around ClientFuture that would match the old Client; if this is something
you would like to see, please file an issue.
2016-11-03 07:12:50 +00:00
2016-06-02 06:24:25 +00:00
### Unique client side implementations
These are standards supported by the DNS protocol. The client implements them
as high level interfaces, which is a bit more rare.
2016-06-02 06:24:25 +00:00
| Feature | Description |
|---------|-------------|
| [SecureSyncClient](https://docs.rs/trust-dns/0.11.0/trust_dns/client/struct.SecureSyncClient.html) | DNSSec validation |
| [create](https://docs.rs/trust-dns/0.11.0/trust_dns/client/trait.Client.html#method.create) | atomic create of a record, with authenticated request |
| [append](https://docs.rs/trust-dns/0.11.0/trust_dns/client/trait.Client.html#method.append) | verify existence of a record and append to it |
| [compare_and_swap](https://docs.rs/trust-dns/0.11.0/trust_dns/client/trait.Client.html#method.compare_and_swap) | atomic (depends on server) compare and swap |
| [delete_by_rdata](https://docs.rs/trust-dns/0.11.0/trust_dns/client/trait.Client.html#method.delete_by_rdata) | delete a specific record |
| [delete_rrset](https://docs.rs/trust-dns/0.11.0/trust_dns/client/trait.Client.html#method.delete_rrset) | delete an entire record set |
| [delete_all](https://docs.rs/trust-dns/0.11.0/trust_dns/client/trait.Client.html#method.delete_all) | delete all records sets with a given name |
| [notify](https://docs.rs/trust-dns/0.11.0/trust_dns/client/trait.Client.html#method.notify) | notify server that it should reload a zone |
### DNS over TLS on the Client
DNS over TLS is supported. This is accomplished through the use of `rust-native-tls`. To use DNS over TLS with the `Client`, the `TlsClientConnection` should be used. See the `TlsClientConnectionBuilder::add_ca()` method. Similarly, to use the tokio `ClientFuture` the `TlsClientStream` should be used. ClientAuth, mTLS, is currently not supported, there are some issues still being worked on. TLS is supported for Server validation and connection privacy.
## Server
2015-08-14 23:28:01 +00:00
2015-11-16 04:57:59 +00:00
The server code is complete, the daemon supports IPv4 and IPv6, UDP and TCP.
2016-06-21 06:28:34 +00:00
There currently is no way to limit TCP and AXFR operations, so it is still not
recommended to put into production as TCP can be used to DOS the service.
Master file parsing is complete and supported. There is currently no forking
option, and the server is not yet threaded (although it is implemented with
async IO, so threading may not be a huge benefit). There is still a lot of work
to do before a server can be trusted with this externally. Running it behind a
firewall on a private network would be safe.
2016-06-21 06:28:34 +00:00
Zone signing support is complete, to insert a key store a pem encoded rsa file
in the same directory as the initial zone file with the `.key` suffix. *Note*:
this must be only readable by the current user. If one is not present one will
be created and written to the correct location. This also acts as the initial
key for dynamic update SIG(0) validation. To get the public key, the `DNSKEY`
record for the zone can be queried. This is needed to provide to other
upstream servers to create the `DS` key. Dynamic DNS is also complete,
if enabled, a journal file will be stored next to the zone file with the
`jrnl` suffix. *Note*: if the key is changed or updated, it is currently the
operators responsibility to remove the only public key from the zone, this
allows for the `DNSKEY` to exist for some unspecified period of time during
key rotation. Rotating the key currently is not available online and requires
a restart of the server process.
### DNS over TLS on the Server
Support of TLS on the Server is managed through a pkcs12 der file. The documentation is captured in the example test config file, [example.toml](https://github.com/bluejekyll/trust-dns/blob/master/server/tests/named_test_configs/example.toml). A registered certificate to the server can be pinned to the Client with the `add_ca()` method. Alternatively, as the client uses the rust-native-tls library, it should work with certificate signed by any standard CA.
2016-03-10 06:50:11 +00:00
## DNSSec status
Currently the root key is hardcoded into the system. This gives validation of
2016-06-21 06:28:34 +00:00
DNSKEY and DS records back to the root. NSEC is implemented, but not NSEC3.
Because caching is not yet enabled, it has been noticed that some DNS servers
appear to rate limit the connections, validating RRSIG records back to the root
can require a significant number of additional queries for those records.
2015-08-22 00:29:00 +00:00
2016-06-02 06:24:25 +00:00
Zones will be automatically resigned on any record updates via dynamic DNS.
2015-10-17 22:33:13 +00:00
## RFC's implemented
2015-09-17 21:13:01 +00:00
2015-11-16 04:57:59 +00:00
### Basic operations
2017-09-25 10:50:34 +00:00
- [RFC 1035](https://tools.ietf.org/html/rfc1035): Base DNS spec (see the Resolver for caching)
- [RFC 2308](https://tools.ietf.org/html/rfc2308): Negative Caching of DNS Queries (see the Resolver)
2015-11-16 04:57:59 +00:00
- [RFC 2782](https://tools.ietf.org/html/rfc2782): Service location
2017-09-25 10:50:34 +00:00
- [RFC 3596](https://tools.ietf.org/html/rfc3596): IPv6
- [RFC 6891](https://tools.ietf.org/html/rfc6891): Extension Mechanisms for DNS
2015-11-16 04:57:59 +00:00
### Update operations
2015-10-18 20:45:31 +00:00
- [RFC 2136](https://tools.ietf.org/html/rfc2136): Dynamic Update
2015-10-17 22:33:13 +00:00
2016-03-10 06:50:11 +00:00
### Secure DNS operations
- [RFC 3007](https://tools.ietf.org/html/rfc3007): Secure Dynamic Update
- [RFC 4034](https://tools.ietf.org/html/rfc4034): DNSSEC Resource Records
- [RFC 4035](https://tools.ietf.org/html/rfc4035): Protocol Modifications for DNSSEC
- [RFC 4509](https://tools.ietf.org/html/rfc4509): SHA-256 in DNSSEC Delegation Signer
- [RFC 5702](https://tools.ietf.org/html/rfc5702): SHA-2 Algorithms with RSA in DNSKEY and RRSIG for DNSSEC
- [RFC 6840](https://tools.ietf.org/html/rfc6840): Clarifications and Implementation Notes for DNSSEC
- [RFC 6944](https://tools.ietf.org/html/rfc6944): DNSKEY Algorithm Implementation Status
- [RFC 6975](https://tools.ietf.org/html/rfc6975): Signaling Cryptographic Algorithm Understanding
- [RFC 7858](https://tools.ietf.org/html/rfc7858): DNS over TLS
2016-03-10 06:50:11 +00:00
2015-10-17 22:33:13 +00:00
## RFC's in progress or not yet implemented
2015-11-16 04:57:59 +00:00
### Basic operations
- [RFC 2317](https://tools.ietf.org/html/rfc2317): Classless IN-ADDR.ARPA delegation
### Update operations
2015-10-18 20:45:31 +00:00
- [RFC 1995](https://tools.ietf.org/html/rfc1995): Incremental Zone Transfer
- [RFC 1996](https://tools.ietf.org/html/rfc1996): Notify secondaries of update
2015-11-16 04:57:59 +00:00
- [Update Leases](https://tools.ietf.org/html/draft-sekar-dns-ul-01): Dynamic DNS Update Leases
- [Long-Lived Queries](http://tools.ietf.org/html/draft-sekar-dns-llq-01): Notify with bells
### Secure DNS operations
- [RFC 5155](https://tools.ietf.org/html/rfc5155): DNSSEC Hashed Authenticated Denial of Existence
2015-10-18 20:45:31 +00:00
- [DNSCrypt](https://dnscrypt.org): Trusted DNS queries
- [S/MIME](https://tools.ietf.org/html/draft-ietf-dane-smime-09): Domain Names For S/MIME
2015-10-17 22:33:13 +00:00
# Usage
2015-10-18 20:45:31 +00:00
This assumes that you have [Rust](https://www.rust-lang.org) stable installed. These
presume that the trust-dns repos have already been synced to the local system:
2015-10-18 20:51:12 +00:00
$ git clone https://github.com/bluejekyll/trust-dns.git
$ cd trust-dns
2015-10-18 20:45:31 +00:00
## Prerequisites
- openssl development libraries (optional in client, min version 1.0.2)
- sqlite3 development libraries (server only)
2016-08-27 04:51:06 +00:00
### Mac OS X: using homebrew
2016-07-25 13:06:39 +00:00
2016-08-27 04:51:06 +00:00
```
$ brew install openssl
$ brew install sqlite
$ export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include
$ export OPENSSL_LIB_DIR=`brew --prefix openssl`/lib
```
### Debian-based (includes Ubuntu & Raspbian): using apt-get
```
2017-03-26 02:01:29 +00:00
# note for openssl that a minimum version of 1.0.2 is required for TLS,
# if this is an issue, TLS can be disabled (on the client), see below.
2016-08-27 04:51:06 +00:00
$ apt-get install openssl
$ apt-get install libssl-dev
$ apt-get install libsqlite3-dev
```
2015-10-18 20:45:31 +00:00
## Testing
- Unit tests
These are good for running on local systems. They will create sockets for
local tests, but will not attempt to access remote systems. Tests can also
be run from the crate directory, i.e. `client` or `server` and `cargo test`
2015-10-18 20:51:12 +00:00
2016-08-27 04:51:06 +00:00
```
$ scripts/run_tests.sh
2016-08-27 04:51:06 +00:00
```
2015-10-18 20:45:31 +00:00
- Functional/Integration tests
2015-10-18 20:45:31 +00:00
These will try to use some local system tools for compatibility testing,
and also make some remote requests to verify compatibility with other DNS
systems. These can not currently be run on Travis for example.
2015-10-18 20:51:12 +00:00
2016-08-27 04:51:06 +00:00
```
$ scripts/run_tests.sh -- --ignored
2016-08-27 04:51:06 +00:00
```
2015-10-18 20:45:31 +00:00
- Benchmarks
Waiting on benchmarks to stabilize in mainline Rust.
## Building
- Production build, first change directories into either the crate directory, `client` or `server`
2015-10-18 20:51:12 +00:00
2016-08-27 04:51:06 +00:00
```
$ cargo build --release
```
2015-10-18 20:45:31 +00:00
## Running
Warning: Trust-DNS is still under development, running in production is not
recommended. The server is currently only single-threaded, it is non-blocking
so this should allow it to work with most internal loads.
- Verify the version
2015-10-18 20:51:12 +00:00
2016-08-27 04:51:06 +00:00
```
$ server/target/release/named --version
2016-08-27 04:51:06 +00:00
```
2015-10-18 20:45:31 +00:00
- Get help
2015-10-18 20:51:12 +00:00
2016-08-27 04:51:06 +00:00
```
$ server/target/release/named --help
2016-08-27 04:51:06 +00:00
```
2015-08-14 23:28:01 +00:00
## Using as a dependency
The Client has a few features which can be disabled for different reasons when embedding in other software.
- `dnssec-openssl` *default*
2017-03-26 02:01:29 +00:00
It is a default feature, so default-features will need to be set to false (this will disable all other default features in trust-dns). Until there are other crypto libraries supported, this will also disable DNSSec validation. The functions will still exist, but will always return errors on validation. The below example line will disable all default features and enable OpenSSL, remove `"openssl"` to remove the dependency on OpenSSL.
- `dnssec-ring`
Ring support can be used for RSA and ED25519 DNSSec validation.
```
[dependencies]
...
trust-dns = { version = "*", default-features = false, features = ["dnssec-openssl"] }
```
2015-08-14 23:28:01 +00:00
# FAQ
2015-10-18 20:51:12 +00:00
- Why are you building another DNS server?
2015-08-14 23:28:01 +00:00
2015-11-16 04:57:59 +00:00
Because of all the security advisories out there for BIND.
2015-08-14 23:28:01 +00:00
Using Rust semantics it should be possible to develop a high performance and
safe DNS Server that is more resilient to attacks.
## License
Licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.