• Stars
    star
    145
  • Rank 254,144 (Top 6 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

What is this?

A toy DNS for hobbyists and worried people.

Several goals:

  • Rule engine to rewrite/deny queries (implemented)
  • Dirt simple to configure (toml syntax)
  • No fat. Fast.

Configuration

Take a look at the content of the config.toml.template file. Copy it to config.toml and run.

RFC2136 and LetsEncrypt compatibility

It is possible to run e.g. certbot and use this software to automatically provide the answers that LetsEncrypt needs to validate that it can deliver a certificate for a given domain:

certbot certonly --test-cert -m [email protected] \
    --config-dir . --work-dir . --logs-dir . \
    --dns-rfc2136 \
    --dns-rfc2136-propagation-seconds 5 \
    --dns-rfc2136-credentials=secrets.ini \
    -d yourhost.example.com

Note: remove --test-cert to get a production certificate.

DNS Synchronization

There is currently no notion of primary and secondary DNS. All your DNS instances are equal. It would be fairly easy to implement IXFR/AXFR but unless it becomes a mandatory feature, this seems to go against my "no fat/easy to configure" goals. With this being said, you could use something like Syncthing to keep config.toml current.

Tell me more about the DNS repository

In the github.com/miekg/dns repository, there was a pull request allowing code using that library to retrieve additional information about the requesting socket. This includes source IP, which can be convenient in a split horizon environment. It lives in this directory (slightly adapted)

Performance testing

The tests below are performed using authoritative (local) records as my main goal is to offer a server that can survive a brutal assault serving cloud endpoints. Performing the same test against recursed hosts offers similar performance, simply because I am not querying 1M different hosts and the server efficiently* caches responses (while respecting their TTL)

These tests are run locally on a 2020 Macbook M1 Pro and jMeter is using as much CPU as it dares to, while kittendns doesn't even appear in my top output.

(*) dumbly

jMeter stress testing

  1. Run Wireshark to capture a DNS query. In the details window, select the Domain Name System layer, right-click, copy as a hex stream.
  2. In jMeter, paste in the "Request Data" area

The jMeter test plan is stored in KittenDNS jMeter Test Plan.jmx

Since we are testing DDoS-type scenarios, we are not going to allow any ramp-up. All clients will be hitting the servers from the beginning.

Results:

Scenario Queries/Minute Queries/Second
1M queued queries for locally resolved hosts 1.3M 21,666
1M queued queries for locally resolved, CNAME'd hosts 1.276M 21,417
1M queries, but by 100 users, no ramp-up 4.599M 76,650
1M queries, 100 users, flattening enabled 4.623M 77,050
1M queries, bump to 1,000 users 3.2M 53,333

Observations:

  • If we distribute across 1000 users rather than 100, threading starts degrading.
  • Flattening doesn't provide the expected level of improvement.

Latency is pretty good, too.

Mig testing

https://github.com/infobloxopen/dnstools/tree/master/mig

./mig -s 192.168.1.189 -n 1000000 -d domains.lst -o perf.json
python2 ../analyser/fit.py results/perf.json

Results:

Rule Engine Queries/Minute Queries/Second
Enabled 6.7M 111,677
Disabled 6.79M 113,181

Again, a somewhat unexpected result: a lightly loaded rule engine has almost no impact on the server's performance.

Todo

Cache improvements

  • If flattening is enabled, we should cache the flattened version.
  • When flattening, what about recursed and fragmented answers?

Circuit Breaker (when recursing)/Rate Limiter

Because, realistically, it is better to fail some queries if this will allow them to succeed later.

Rate Limiter: should be limiting some misbehaving clients. Problem: how do we identify a "Client?"

  • Is a client a single IP address? If it's a site DNS proxying to us, then it may be allowed higher traffic levels
  • Should we throttle a combination of source + queries?

FAQ

Q: I noticed that you are storing similar records in separate structures. For instance, there is one entry for a A (v4) record, and another entry for its AAAA (v6) counterpart. This is wastful!

A: You are correct. However, I should not store both entries using the same key because they can both be capitalized differently. And, little known fact, capitalization in DNS can be a security feature.

Misc

Logo created by DesignEvo logo maker

More Repositories

1

libui.cr

Crystal-lang bindings for libui
Crystal
176
star
2

pngsource

Embed Embed source code in png files
HTML
107
star
3

pywhistle

Unofficial Whistle 3 API consumer
Python
20
star
4

RootTools

Root Tools
Java
19
star
5

extphp

This is the ExtPHP wrapper I wrote before ExtJS changed license.
11
star
6

krew-plugins-for-m1

Kubectl Krew plugins built for Mac M1 processors
Shell
11
star
7

CActor

The Actor Model for Plain Old C
C
11
star
8

crystalvault

A zero-knowledge server to store and share secrets: credentials, keys, etc.
HTML
9
star
9

Twitterified

The Twitterified Client, fully open-sourced
ActionScript
9
star
10

s2ajax

The awesome Sajax for Python/PHP, but for Python, including 3.0, and PHP5, with objects support.
PHP
8
star
11

crafty-things

A CraftX Extension
TypeScript
6
star
12

SuperBomberGame

This is not a complete game, but small demo of how one could write a game loop in ReasonML.
Reason
6
star
13

sbase-for-android

Shell tools that suck less!
C
5
star
14

data.cr

A bumbling foray in immutable data structures land. In Crystal!
Crystal
5
star
15

ztncli

A companion CLI for Key Network's ztncui ZeroTier controller interface
Shell
5
star
16

modernfbv

Go
4
star
17

applekeyboarddriver

A laptop/PS2 keyboard driver for recalcitrant laptops/desktops running Leopard...er Darwin
C++
4
star
18

NativeTools

C++
3
star
19

mailbiter

Go
3
star
20

n2

n2: More ketchup.
PHP
3
star
21

wekanapi

A standalone API for Wekan
Crystal
2
star
22

BambooGarden

Using RootTools' new Java interfaces, handle multiple notebooks in Wacom's Bamboo Paper
Java
2
star
23

U-Must-Sync

Currently, non-functional code to synchronize Toodledo and The Hit List
2
star
24

crystal-pack

A partial implementation of pack() and unpack() for the Crystal language
Crystal
2
star
25

reasonable-fidelity

Replay recorded web sessions, check for fidelity
Python
2
star
26

slotmachine

Find a free slot in a slice, quick, in Go
Go
2
star
27

lenses

PHP Framework
PHP
2
star
28

shl

Execute from shell some commands that query online services
Go
1
star
29

php-error-reporter

Display stack traces, variables states, and will try to notify you
1
star
30

ezedit

Edit any web page. Easily. Very very easily.
PHP
1
star
31

CFRAnimated

A "compressed time" animation library for Android (currently Canvas)
Java
1
star
32

glauth-qr-code-rust

Rust
1
star
33

mezzanine-mollom

Mollom SPAM filter for Mezzanine CMS
Python
1
star
34

awesome-supervisor

A curated list of supervisor(d) configurations, etc
Shell
1
star
35

cfr_minimal_shell

This is my minimal shell tarball. Use it if you must, but it's not an actual project.
Vim Script
1
star
36

php-migrate

A migration tool, relying on YAML syntax, for your PHP projects
1
star
37

crystal-block

Highlight matching Crystal block in Atom editor
CoffeeScript
1
star