• Stars
    star
    392
  • Rank 109,735 (Top 3 %)
  • Language
    Erlang
  • License
    MIT License
  • Created over 12 years ago
  • Updated 8 months ago

Reviews

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

Repository Details

DNS server, in Erlang.

Erlang DNS Server

Serve DNS authoritative responses... with Erlang.

CI

Building

To build:

make

To start fresh:

make fresh
make

Zones

Zones are loaded from JSON. Example JSON files are in the priv/ directory.

You can also write new systems to load zones by writing the zones directly to the zone cache using erldns_zone_cache:put_zone/1.

Configuration

An example configuration file can be found in erldns.example.config. Copy it to erldns.config and modify as needed.

Running

Launch directly:

overmind start

To get an interactive Erlang REPL:

./rebar3 shell

Build a distribution with and run the release:

./rebar3 release
./_build/default/rel/erldns/bin/erldns foreground

Querying

Here are some queries to try:

dig -p 8053 @127.0.0.1 example.com a
dig -p 8053 @127.0.0.1 example.com cname
dig -p 8053 @127.0.0.1 example.com ns
dig -p 8053 @127.0.0.1 example.com mx
dig -p 8053 @127.0.0.1 example.com spf
dig -p 8053 @127.0.0.1 example.com txt
dig -p 8053 @127.0.0.1 example.com sshfp
dig -p 8053 @127.0.0.1 example.com soa
dig -p 8053 @127.0.0.1 example.com naptr

dig -p 8053 @127.0.0.1 -x 127.0.0.1 ptr

Performance

In our environment (DNSimple) we are seeing 30 to 65 ยตs handoff times to retrieve a packet from the UDP port and give it to a worker for processing. Your performance may vary, but given those measurements erl-dns is capable of handling between 15k and 30k questions per second. Please note: You may need to configure the number of workers available to handle traffic at higher volumes.

Design

The erldns_resolver module will attempt to find zone data in the zone cache. If you're embedding erl-dns in your application the easiest thing to do is to load the zone cache once the zone cache gen_server starts push an updated zone into the cache each time data changes.

To insert a zone, use erldns_zone_cache:put_zone({Name, Records}) where Name is a binary term such as <<"example.com">> and Records is a list of dns_rr records (whose definitions can be found in deps/dns/include/dns_records.hrl). The name of each record must be the fully qualified domain name (including the zone part).

Here's an example:

erldns_zone_cache:put_zone({
  <<"example.com">>, [
    #dns_rr{
      name = <<"example.com">>,
      type = ?DNS_TYPE_A,
      ttl = 3600,
      data = #dns_rrdata_a{ip = {1,2,3,4}}
    },
    #dns_rr{
      name = <<"www.example.com">>,
      type = ?DNS_TYPE_CNAME,
      ttl = 3600,
      data = #dns_rrdata_cname{dname = <<"example.com">>}
    }
  ]}).

Metrics

Folsom is used to gather runtime metrics and statistics.

There is an HTTP API for querying metric data available at https://github.com/dnsimple/erldns-metrics

Tracing

This project uses OpenTelemetry (OTEL) Tracing to provide telemetry data on request processing inside of erldns.

To enable opentelmetry tracing, you need to:

  1. Add opentelemetry as dependency of your application.

  2. Configure the opentelemetry client:

    Add the following configuration to the erldns.config:

      {opentelemetry,[
        {processors,
            [{otel_batch_processor,
                #{exporter => {opentelemetry_exporter, #{protocol => http_protobuf,
                                                        endpoints => [{http, "127.0.0.1", 55681, []}]}}}}]}
      ]}

NOTE: You will need to have a running OpenTelemetry Collector.

Application traces:

Name Dimensions
erldns_tcp_worker
handle_tcp_dns_query status, qr, rd, ad, qname, qtype
handle_decoded_tcp_message status
send_tcp_message
erldns_udp_worker host, port, erlang_port_count, erlang_proc_count, erlang_run_queue, erlang_proc_message_queue_len, status
handle_udp_dns_query status, qr, rd, ad, qname, qtype
handle_decoded_udp_message status
synthesize_answer
encode_message rcode, aa, ra, answers

Admin

There is an administrative API for querying the current zone cache and for basic control. You can find it in https://github.com/dnsimple/erldns-admin

More Repositories

1

dnsimple-ruby

The DNSimple API client for Ruby.
Ruby
188
star
2

dns_erlang

Erlang DNS library.
Erlang
94
star
3

dnsimple-go

The DNSimple API client for Go.
Go
75
star
4

dnsimple-python

The DNSimple API client for Python.
Python
65
star
5

dnsimple-services

One-click service configurations for DNSimple.
Ruby
51
star
6

dnsimple-elixir

The DNSimple API client for Elixir.
Elixir
50
star
7

dnsimple-node

The DNSimple API client for Node.js.
TypeScript
48
star
8

chef-dnsimple

Chef cookbook for DNSimple.
Ruby
38
star
9

dnsimple-developer

The DNSimple API Documentation.
HTML
35
star
10

erldns-admin

Admin API for erldns.
Erlang
26
star
11

dnsimple-api-examples

Example scripts and code to demonstrate how to use the DNSimple API.
Ruby
26
star
12

dnstest

Erlang app for testing authoritative DNS servers for compliance.
Erlang
24
star
13

chef-pdns

Development repository for DNSimple Cookbook PowerDNS.
Ruby
23
star
14

strillone

Listen to incoming webhooks from DNSimple, and publish them to a Slack channel or other messaging service.
Go
23
star
15

terraform-provider-dnsimple

Terraform DNSimple provider.
Go
21
star
16

go-remote-control

Daemon that runs on hosts and provides limited remote control access.
Go
20
star
17

exdns

Elixir port of erldns.
Elixir
16
star
18

erldns-metrics

Metrics endpoint for erldns.
Erlang
12
star
19

base32_erlang

Erlang implementation of base32 encoding and decoding.
Erlang
12
star
20

dnsimple-support

HTML
12
star
21

dnsimple-csharp

The DNSimple API client for C#.
C#
12
star
22

dnsimple-rust

The DNSimple API client for Rust.
Rust
10
star
23

dnsimple-php

The DNSimple API client for PHP.
PHP
10
star
24

dnsimple-java

The DNSimple API client for Java.
Java
8
star
25

dnsimple-elixir-cli

An example of a CLI for DNSimple built in Elixir.
Elixir
7
star
26

addon-digitalocean

A connector add-on for Digital Ocean
Elixir
5
star
27

hello-domains-hanami

Hello Domains, the Hello World for the DNSimple API, implemented with Ruby & Hanami
Ruby
4
star
28

hello-domains-rails

Hello Domains, the Hello World for the DNSimple API, implemented with Ruby & Rails
Ruby
4
star
29

coredns-dnsimple

A DNSimple plugin for CoreDNS.
Go
4
star
30

dnsimple-ruby-cli

An example of a CLI for DNSimple built in Ruby.
Ruby
3
star
31

terraform-dnsimple-cts

DNSimple Consult-Terraform-Sync NIA integration to manage your DNS records.
HCL
3
star
32

hello-domains-node

Hello Domains, the Hello World for the DNSimple API, implemented in Node.js
JavaScript
3
star
33

omniauth-dnsimple

DNSimple strategy for OmniAuth
Ruby
2
star
34

hubot-dnsimple

A hubot script that interacts with DNSimple.
CoffeeScript
2
star
35

addon-github-pages

Connector for GitHub Pages
Elixir
1
star
36

hello-domains-phoenix

Hello Domains, the Hello World for the DNSimple API, implemented in Elixir & Phoenix
Elixir
1
star
37

chef-dnsimple_demo

A demo for conventions and webinars.
Ruby
1
star
38

policy-library-dnsimple-terraform

Prescriptive Sentinel Policies for Establishing Secure Terraform Configurations for Domains and DNS in DNSimple
HCL
1
star
39

addon-export-csv

Export your domains in CSV format with this simple addon
Ruby
1
star
40

addon-email-report

Add-on to send regular domain reports via email
Elixir
1
star
41

addon-heroku

Connect DNSimple domains to Heroku apps
Elixir
1
star